Thanks! Works like a charm.
Ed
On Tue, 4 Nov 2003, CPT John W. Holmes wrote:
> From: "Ed Curtis" <[EMAIL PROTECTED]>
> > 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?
>
> $new_number = preg_replace('/\.[0-9]+/','',$old_number);
>
> I would do that first, then a
>
> $new_number = preg_replace('/[^0-9]/','',$new_number);
>
> afterwards to remove anything that's not a number from the string.
>
> ---John Holmes...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php