note 68821 deleted from function.round by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:20:37 +0000 |
| Subject: | note 68821 deleted from function.round by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154800@lists.php.net to get a copy of this message | ||
Note Submitter: ionut dot socol at euromarket dot ro
----
My name is Ionut Socol and i'm from Romania
A small script that allow you to round up, round down or just return the integer number.
The $direction value cand be:
0 - rounding down
1 - rounding up
any thing else for returning the integer value
<?php
function rounding($no,$direction)
{ $skip=0;
if(is_float($no) and $direction = 1)
{
$exploded = explode(".",$no);
$nrr = $exploded[0]+1; $skip=1;
}
if(is_float($no) and $direction = 0)
{
$exploded = explode(".",$no);
$nrr = $exploded[0]; $skip=1;
}
if(!is_float($no) and $skip ==1) { $nrr = $nrr; } else { $nrr = floor($nrr); }
return $nrr;
}
?>