skeezmo Posted February 26, 2006 Share Posted February 26, 2006 I have found on php.net, [b]that sprintf("%01.2f", $money);[/b] will echon out to decimal place holders for currency. What I am looking for is for this to only take place if in the database there happen to be cents attached to the dollar. Otherwise, it just stays the same (no decimals).Does anyone know how I'd achieve this? Link to comment https://forums.phpfreaks.com/topic/3638-sprintf/ Share on other sites More sharing options...
Barand Posted February 27, 2006 Share Posted February 27, 2006 [code]$money = 200.00;if (intval($money)==$money) { $val = sprintf('$%d', $money);}else { $val = sprintf('$%01.2f', $money);}echo $val;[/code] Link to comment https://forums.phpfreaks.com/topic/3638-sprintf/#findComment-12654 Share on other sites More sharing options...
skeezmo Posted February 27, 2006 Author Share Posted February 27, 2006 thanks Link to comment https://forums.phpfreaks.com/topic/3638-sprintf/#findComment-12655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.