Re: number format?
| From: | Leif Gregory | Date: | Tue, 10 May 2005 17:52:56 +0000 |
| Subject: | Re: number format? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214859@lists.php.net to get a copy of this message | ||
Hello Dustin,
Tuesday, May 10, 2005, 9:34:10 AM, you wrote:
D> I have a number like -56.98
D> I need to convert it to -5698. I tried
<?php
$num = -56.98;
$newNum = str_replace(".","",$num);
echo "newNum = " . $newNum;
$add50 = $newNum + 50;
echo "<br>Add50 = " . $add50;
$sub50 = $newNum -50;
echo "<br>Sub50 = " . $sub50;
?>
If you still need to do math on it, just remember you don't have a
decimal anymore. See example above. Make sure you do any math you need
to do before the str_replace. If you're just displaying it, then no
problem.
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.5 Return RC5 under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB