JustinK101 Posted August 24, 2007 Share Posted August 24, 2007 $myNumb = -123; I am trying to do number_format($myNumb, 2) which I would expect to return -123.00, but it returns 0. How do I get around this? Thanks. Link to comment https://forums.phpfreaks.com/topic/66479-number_format-cannot-take-in-negative-number/ Share on other sites More sharing options...
Barand Posted August 24, 2007 Share Posted August 24, 2007 <?php $numb = -123; echo number_format($numb, 2); // --> -123.00 ?> ??? Can't see a problem Link to comment https://forums.phpfreaks.com/topic/66479-number_format-cannot-take-in-negative-number/#findComment-332846 Share on other sites More sharing options...
xyn Posted August 24, 2007 Share Posted August 24, 2007 I would do something like... $number = "-12345"; $number = explode("-", $number); $number = "-" . number_format($number, 2, ','); Link to comment https://forums.phpfreaks.com/topic/66479-number_format-cannot-take-in-negative-number/#findComment-332847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.