2DaysAway Posted October 4, 2008 Share Posted October 4, 2008 Ok, I have a list of these functions on a separate php file and I use the include() statement on another php file to load this function page into it. The functions work properly but for every function I use a 0 appears at the top of the DIV the include() statement is in. So, I have exactly nine 0's in a row because I have nine separate functions. Any ideas what is going on here? lol. $mint = $user["medicine"]; function mformat($number) { $suffix = array('', ' K', ' M', ' B',' T', ' Q'); $max = count($suffix) - 1; while ($number >= 1000 and $i < $max){ $number /= 1000; $i++; } $number = round($number, 2); return $number . $suffix[$i]; } echo mformat($mint); Link to comment https://forums.phpfreaks.com/topic/126959-mysterious-0-appear-with-this-function/ Share on other sites More sharing options...
DarkWater Posted October 4, 2008 Share Posted October 4, 2008 Must be coming from somewhere else, because I just did: <?php $mint = 56000; function mformat($number) { $suffix = array('', ' K', ' M', ' B',' T', ' Q'); $max = count($suffix) - 1; while ($number >= 1000 and $i < $max){ $number /= 1000; $i++; } $number = round($number, 2); return $number . $suffix[$i]; } echo mformat($mint); And it worked fine. Are you sure $user['medicine'] is not null? Link to comment https://forums.phpfreaks.com/topic/126959-mysterious-0-appear-with-this-function/#findComment-656732 Share on other sites More sharing options...
2DaysAway Posted October 4, 2008 Author Share Posted October 4, 2008 Null is set to no. Link to comment https://forums.phpfreaks.com/topic/126959-mysterious-0-appear-with-this-function/#findComment-656734 Share on other sites More sharing options...
2DaysAway Posted October 4, 2008 Author Share Posted October 4, 2008 I'm looking a few things, i'll get back when I see something.... Link to comment https://forums.phpfreaks.com/topic/126959-mysterious-0-appear-with-this-function/#findComment-656748 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 You are probably echoing a false value (treated as a number). For anyone in a forum to help, you would need to post the relevant code that is producing and outputting content immediate prior to the <div>, i.e. the code responsible for the point in the output where the zero is appearing. Link to comment https://forums.phpfreaks.com/topic/126959-mysterious-0-appear-with-this-function/#findComment-656764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.