note 16407 added to ref.math
| From: | derek at hismail dot com | Date: | Mon, 29 Oct 2001 04:18:46 +0000 |
| Subject: | note 16407 added to ref.math | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19556@lists.php.net to get a copy of this message | ||
Here's a funtcion I wrote to move the decimal point of a number over x spaces.
function movedec ($num , $move){
while(strlen($num) <= $move){
$num = '0'.$num;
$inc++;
}
$num = strrev($num);
$num = eregi_replace("([0-9]{".$move."})([0-9])","\\1.\\2",$num);
$num = strrev($num);
return $num;
}
so
$n = movedec(3456,3);
would output 3.456
if you put
$n = movedec(34,5);
outputs 0.00034
--
http://www.php.net/manual/en/ref.math.php
http://master.php.net/manage/user-notes.php?action=edit+16407
http://master.php.net/manage/user-notes.php?action=delete+16407
http://master.php.net/manage/user-notes.php?action=reject+16407