J'ai un grand tableau contenant beaucoup d'éléments contenant des données numériques.
Exemple: p> Je veux convertir ces en: p> 32.00
343.00
14.99
128.99
3 Réponses :
$new_array=array(); foreach($old_array as $value) { $new_array[]=number_format(($value/100),2); } See number_format if you want to fiddle with the thousands separator or something. See foreach if you want to modify the array values in place.
Utile pour API d'Amazon publicitaire API qui renvoie un objet où le prix est formaté sans aucun point décimal.
ou, si vous aimez les fonctions anonymes et php 5.3: sortie: p> toujours et tout, la réponse est la solution Même: utilisez number_format () code>. p> p>