Jump to content

mysterious '0' appear with this function


2DaysAway

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.