Précédent   Forum des professionnels en informatique > PHP > Scripts
Scripts Forum d'entraide sur les scripts PHP téléchargés. Les meilleurs scripts PHP, la FAQ scripts PHP, toutes les FAQ PHP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 07/01/2011, 12h07   #1
Invité de passage
 
Inscription : janvier 2011
Messages : 1
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 1
Points : 0
Points : 0
Par défaut Convertir un chiffre en lettre

Bonjour,
j'ai trouvé un script qui converti un chiffre en lettre, mais j'ai un problème des virgules.par exemple lorsque je veux convertir 10.20 il me donne dix virgule deux
même si j'ai utilisé la fonction number_format($chiffre, 2, '.', '');
Merci infiniment de votre passage.
le script est :
Code :
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"; 
?>
souriante2011 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2011, 13h37   #2
Membre Expert
 
Avatar de Seb33300
 
Homme Sébastien Alfaiate
Développeur Web
Inscription : janvier 2007
Messages : 1 329
Détails du profil
Informations personnelles :
Nom : Homme Sébastien Alfaiate
Âge : 26
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : janvier 2007
Messages : 1 329
Points : 1 657
Points : 1 657
Et toi tu voudrais avoir quel résultat ?
__________________
Zend Certified Engineer PHP 5.3

« Crois-tu comprendre le monde juste en matant le 20H Ou connaître l'histoire en ayant lu que l'angle des vainqueurs ? » Keny Arkana
Seb33300 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h42.


 
 
 
 
Partenaires

Hébergement Web