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. Quote 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 Quote 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, ','); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.