note 110668 added to function.round
| From: | jmisasa at gmail dot com | Date: | Wed, 21 Nov 2012 11:33:07 +0000 |
| Subject: | note 110668 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192052@lists.php.net to get a copy of this message | ||
If you're using a PHP version prior to 5.3 and you need to use the PHP_ROUND_HALF_DOWN feature
then this might be helpful:
<?php
function round_half_down (&$value)
{
if (!ctype_digit ((string)($value*2))) {
$value = round ($value);
}
else {
$value = floor ($value);
}
}
$value = 10.5;
round_half_down ($value);
echo $value; // will print '10'
?>
----
Server IP: 69.147.83.199
Probable Submitter: 83.42.11.183
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/110668
Del: integrated -- https://master.php.net/note/delete/110668/integrated
Del: useless -- https://master.php.net/note/delete/110668/useless
Del: bad code -- https://master.php.net/note/delete/110668/bad+code
Del: spam -- https://master.php.net/note/delete/110668/spam
Del: non-english -- https://master.php.net/note/delete/110668/non-english
Del: in docs -- https://master.php.net/note/delete/110668/in+docs
Del: other reasons-- https://master.php.net/note/delete/110668
Reject -- https://master.php.net/note/reject/110668
Search -- https://master.php.net/manage/user-notes.php