note 16407 deleted from ref.math by jimw
| From: | jimw@php.net | Date: | Mon, 29 Oct 2001 04:30:58 +0000 |
| Subject: | note 16407 deleted from ref.math by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19557@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