RE: [PHP] Stripping Decimals
| From: | Jay Blanchard | Date: | Tue, 04 Nov 2003 15:36:05 +0000 |
| Subject: | RE: [PHP] Stripping Decimals | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-168474@lists.php.net to get a copy of this message | ||
[snip]
I currently use number_format() and str_replace() to remove a "," or
"$"
if entered and reformat it as a price for an item. I've asked the
user not to use decimals but some still do. How do I remove a decimal
and
anything after from a number in a varable?
[/snip]
http://www.php.net/explode
$dollar = "100.28";
$newDollar = explode(".", $dollar);
echo $newDollar[0];