Reply to Re: number_format() question EASY

Your name:

Reply:


Posted by ED on 02/21/07 18:56

"rynTAU" <rtaube@gmail.com> wrote in message
news:1172083571.684502.15110@h3g2000cwc.googlegroups.com...
> 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.
>

You just need to cast to an integer, ie:

$num= 23.34567;
$num = (int) $num;

$num then equals 23,
cheers,
ED

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация