RE: [PHP] How do i assign Integers only and not real numbers?
| From: | M dot A dot Bond at open dot ac dot uk | Date: | Mon, 23 Sep 2002 14:49:15 +0000 |
| Subject: | RE: [PHP] How do i assign Integers only and not real numbers? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-117281@lists.php.net to get a copy of this message | ||
You could cast it to an int, although the manual warns that you can get
spurious errors upon casting an unknown fraction, so be careful.
$year= (int) ($years);
Mark
-----Original Message-----
From: Tom [mailto:tom.callaghan@claimnet.co.uk]
Sent: 23 September 2002 15:47
To: php-general@lists.php.net
Subject: [PHP] How do i assign Integers only and not real numbers?
Hi all,
I have a line of code that assigns a new year number: -
$years = $years + ( $themonth / 12 );
but sometimes $years == 1998.0833333333
or
$year == 2002.75
etc...
I cant find anything like a round() or floor() function in PHP so that year
would be 1998 or 2002 only.
Does anyone know what function would do this? Sorry if I`m wasting your
time if its a really obvious one!
thanks in advance,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php