Hey there
i have a variable and i need to make it a float to display later.
i cant use printf() because the value will display text if there is no numeric value
i also cant just set it to a float because i need to have it go to 2 decimal places.
so if $var = 12.3 i will get 12.30
like with money, i dont have .3 dollars, i have 30 cents.
this isnt a money project but the same would apply
lots of docs out there on type conversions, but i couldn't find out how to do this
thanks
need a float with 2 decimal places
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
- wrong forum, PHP - Code is where to post this (the thread will be moved shortly)
- using a combination of is_numeric() with sprintf() should do it nicely...