settembre: 2010
L M M G V S D
« ago    
 12345
6789101112
13141516171819
20212223242526
27282930  

PHP formattare un numero con number_format

Independent Codes

Questo articolo fa parte del progetto Independent Codes
Per formattare un numero in PHP abbiamo a disposizione una funzione molto semplice e più strutturata rispetto ad altri linguaggi, che ci consente, in un solo passaggio, di poter decidere anche i separatori dei decimali e delle migliaia.
La sintassi è number_format(NUMERO, CIFRE_DECIMALI, SEPARATORE_DEC., SEPARATORE_MIGLIAIA)


number_format (1234.567, 2, ',', ' '); //questo restituirà "1 234,57"

Bookmark and Share

Lascia un comento

 

 

 

Puoi usare questi tag

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>