Reply to Re: [PHP] number format?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация