Greetings.
I'm simply needing to turn a string such as ->
'001059'
To a dollar amount
$10.59
I've managed to lose the leading 0's thanks to trim() - but after trying float and floatval neither work for me.
Any suggestions.
thanks
jw
| SitePoint Sponsor |




Greetings.
I'm simply needing to turn a string such as ->
'001059'
To a dollar amount
$10.59
I've managed to lose the leading 0's thanks to trim() - but after trying float and floatval neither work for me.
Any suggestions.
thanks
jw




managed to do this simply by multiply * .01 but there has to be a more professional way of doing this.

//prints $10.59Code:$number_f = 1059 * .01; echo "$".number_format($number_f, 2, '.', ',');
Not really sure if this helps you at all. It just makes the formatting clean.




thanks mk

Or money_format(), exactly for this purpose:
http://php.net/function.money-format
Bookmarks