|
Posted by Jerry Stuckle on 02/22/07 19:36
Curtis wrote:
> Jerry Stuckle wrote:
>> rynTAU wrote:
>>> This is an easy question, I'm sure but I can't seem to figure it
>>> out.
>>>
>>> I'm trying to use the number_format() function to remove all decimal
>>> places from a number.
>>>
>>>
>>> $num = number_format($num, 0, '.', '');
>>>
>>> So if I have 23.34567 I want 23, and 45.8789 will return with 45.
>>> The problem is that the this function rounds the number off. so that
>>> 45.8789 returns 46 instead of 45.
>>>
>>> Is there another function? What should I be using.
>>>
>>> Thanks for your help.
>>>
>>
>> $num = int($num);
>>
>
> Actually, Jerry, your code would produce an E_USER_FATAL, since there is
> no built-in function called int(). Any of these will work:
>
> $n = 25.2829;
> $n = (int) $n;
> $n = intval($n);
> $n = floor($n);
>
> --
> Curtis, http://dyersweb.com
<sheepish grin>
Been doing too much C++ lately, I guess :-)
Thanks for the correction.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|