|
Posted by Leif Gregory on 05/10/05 20:52
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
Navigation:
[Reply to this message]
|