Bonjour,
J’ai installé dans mes_fonctions.php le filtre « Filtre en lettres » (ci-dessous) trouvé sur spip-contrib.
Il me transforme bien les nombres en lettres sauf pour la somme de 100.
Quelqu’un peut-il m’aider à corriger ce problème ?
Merci
<?php function chiffre($unites,$genre=''){ if ($unites==1 AND $genre=='fem'){$retour="une";} if ($unites==1 AND $genre!='fem'){$retour="un";} if ($unites==2){$retour="deux";} if ($unites==3){$retour="trois";} if ($unites==4){$retour="quatre";} if ($unites==5){$retour="cinq";} if ($unites==6){$retour="six";} if ($unites==7){$retour="sept";} if ($unites==8){$retour="huit";} if ($unites==9){$retour="neuf";} return $retour; } function chiffre_sans($unites){ if ($unites==2){$retour="deux";} if ($unites==3){$retour="trois";} if ($unites==4){$retour="quatre";} if ($unites==5){$retour="cinq";} if ($unites==6){$retour="six";} if ($unites==7){$retour="sept";} if ($unites==8){$retour="huit";} if ($unites==9){$retour="neuf";} return $retour; } function chiffre_et($unites, $genre=''){ if ($unites==1 AND $genre=='fem'){$retour=" et une";} if ($unites==1 AND $genre!='fem'){$retour=" et un";} if ($unites==2){$retour="-deux";} if ($unites==3){$retour="-trois";} if ($unites==4){$retour="-quatre";} if ($unites==5){$retour="-cinq";} if ($unites==6){$retour="-six";} if ($unites==7){$retour="-sept";} if ($unites==8){$retour="-huit";} if ($unites==9){$retour="-neuf";} return $retour; } function chiffre_dix($unites){ if ($unites==0){$retour="dix";} if ($unites==1){$retour="onze";} if ($unites==2){$retour="douze";} if ($unites==3){$retour="treize";} if ($unites==4){$retour="quatorze";} if ($unites==5){$retour="quinze";} if ($unites==6){$retour="seize";} if ($unites==7){$retour="dix-sept";} if ($unites==8){$retour="dix-huit";} if ($unites==9){$retour="dix-neuf";} return $retour; } function chiffre_et_dix($unites){ if ($unites==0){$retour="-dix";} if ($unites==1){$retour=" et onze";} if ($unites==2){$retour="-douze";} if ($unites==3){$retour="-treize";} if ($unites==4){$retour="-quatorze";} if ($unites==5){$retour="-quinze";} if ($unites==6){$retour="-seize";} if ($unites==7){$retour="-dix-sept";} if ($unites==8){$retour="-dix-huit";} if ($unites==9){$retour="-dix-neuf";} return $retour; } function dizaines($dizaines,$unites,$genre=''){ if ($dizaines==0){ $retour=chiffre($unites,$genre); } if ($dizaines==1){ $retour=chiffre_dix($unites); } if ($dizaines==2){ $retour="vingt".chiffre_et($unites,$genre); } if ($dizaines==3){ $retour="trente".chiffre_et($unites,$genre); } if ($dizaines==4){ $retour="quarante".chiffre_et($unites,$genre); } if ($dizaines==5){ $retour="cinquante".chiffre_et($unites,$genre); } if ($dizaines==6){ $retour="soixante".chiffre_et($unites,$genre); } if ($dizaines==7){ $retour="soixante".chiffre_et_dix($unites); } if ($dizaines==8 & $unites>0){ $retour="quatre-vingt-".chiffre($unites,$genre); } if ($dizaines==8 & $unites==0){ $retour="quatre-vingts"; } if ($dizaines==9){ $retour="quatre-vingt-".chiffre_dix($unites); } return $retour; } function par3($lavaleur,$demille,$genre='masc',$type=''){ if (strlen($lavaleur)==1){$lavaleur="00".$lavaleur;} if (strlen($lavaleur)==2){$lavaleur="0".$lavaleur;} $centaines=substr($lavaleur,0,1); $dizaines=substr($lavaleur,1,1); $unites=substr($lavaleur,2,1); if ($centaines>1){ $cent="cents"; } if ($demille=="mille"){ $cent="cent"; } if ($dizaines+$unites>0){ $cent="cent"; } if (($demille=="million" OR $demille=="milliard") AND $centaines+$dizaines+$unites>1){ $demille=$demille."s"; } if ($centaines+$dizaines+$unites>0){ $demille=" ".$demille; }else{ $demille=""; } if ($centaines>0){ $retour=chiffre_sans($centaines)." $cent ".dizaines($dizaines,$unites,$genre); }else{ $retour=dizaines($dizaines,$unites,$genre); } if (trim($retour)=="un" & trim($demille)=="mille"){ $retour=""; } if (trim($retour)=="un" AND $type=='date'){ $retour="premier"; if($genre=='fem') $retour="première"; } if($genre=='fem' AND $retour=="un") $retour="une"; return $retour.$demille; } function en_lettres($lavaleur,$genre='masc',$type=''){ $lavaleur=strrev($lavaleur); $unites=par3(strrev(substr($lavaleur,0,3)),"","$genre","$type"); $milliers=par3(strrev(substr($lavaleur,3,3)),"mille"); $millions=par3(strrev(substr($lavaleur,6,3)),"million"); $milliards=par3(strrev(substr($lavaleur,9,3)),"milliard"); return trim("$milliards $millions $milliers $unites"); } function jour_en_lettres($lavaleur){ return en_lettres($lavaleur,'','date'); } function en_lettres_fem($lavaleur){ return en_lettres($lavaleur,'fem',''); } function enlettres($lenombre,$unite='',$unites='',$entre='',$apres='',$apress=''){ $lenombre=ereg_replace(",",".",$lenombre); $lenombre=explode(".",$lenombre); $entier=$lenombre[0]; if ($entier>1 & strlen($unite)>0){ $unite=$unites; } $virgule=$lenombre[1]; if ($virgule>1 & strlen($apres)>0){ $apres=$apress; } if ($entier==0 OR $virgule==0){ $entre=""; } if ($entier==0){ $unite=""; } $entier=en_lettres($entier); if ($virgule==0){ $apres=""; } $virgule=en_lettres($virgule); return trim("$entier $unite $entre $virgule $apres"); } ?>