1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <?php
function int2str($a){
$joakim = explode('.',$a);
if (isset($joakim[1]) && $joakim[1]!=''){
return int2str($joakim[0]).' Dirhams '.int2str($joakim[1]).' Centimes.' ;
}
if ($a<0) return 'moins '.int2str(-$a);
if ($a<17){
switch ($a){
case 0: return 'Zero';
case 1: return 'Un';
case 2: return 'Deux';
case 3: return 'Trois';
case 4: return 'Quatre';
case 5: return 'Cinq';
case 6: return 'Six';
case 7: return 'Sept';
case 8: return 'Huit';
case 9: return 'Neuf';
case 10: return 'Dix';
case 11: return 'Onze';
case 12: return 'Douze';
case 13: return 'Treize';
case 14: return 'Quatorze';
case 15: return 'Quinze';
case 16: return 'Seize';
}
} else if ($a<20){
return 'dix-'.int2str($a-10);
} else if ($a<100){
if ($a%10==0){
switch ($a){
case 20: return 'Vingt';
case 30: return 'Trente';
case 40: return 'Quarante';
case 50: return 'Cinquante';
case 60: return 'Soixante';
case 70: return 'Soixante-Dix';
case 80: return 'Quatre-Vingt';
case 90: return 'Quatre-Vingt-Dix';
}
} elseif (substr($a, -1)==1){
if( ((int)($a/10)*10)<70 ){
return int2str((int)($a/10)*10).'-et-un';
} elseif ($a==71) {
return 'Soixante et onze';
} elseif ($a==81) {
return 'Quatre vingt un';
} elseif ($a==91) {
return 'Quatre vingt onze';
}
} elseif ($a<70){
return int2str($a-$a%10).'-'.int2str($a%10);
} elseif ($a<80){
return int2str(60).'-'.int2str($a%20);
} else{
return int2str(80).'-'.int2str($a%20);
}
} else if ($a==100){
return 'Cent';
} else if ($a<200){
return int2str(100).' '.int2str($a%100);
} else if ($a<1000){
return int2str((int)($a/100)).' '.int2str(100).' '.int2str($a%100);
} else if ($a==1000){
return 'Mille';
} else if ($a<2000){
return int2str(1000).' '.int2str($a%1000).' ';
} else if ($a<1000000){
return int2str((int)($a/1000)).' '.int2str(1000).' '.int2str($a%1000);
}
}
echo int2str($a)." Dirhams";
?> |
Partager