Logo

Programming-Idioms

History of Idiom 65 > diff from v18 to v19

Edit summary for version 19 by :
New PHP implementation by user [agilla1]

Version 18

2016-02-18, 16:58:00

Version 19

2016-03-02, 13:29:57

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Code
$s = number_format($x * 100.0, 1) . '%';
Doc URL
http://php.net/manual/en/function.number-format.php