Re: Removing commas from number
| From: | Tijnema ! | Date: | Sun, 06 May 2007 15:38:51 +0000 |
| Subject: | Re: Removing commas from number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254487@lists.php.net to get a copy of this message | ||
On 5/6/07, Todd Cary <todd@aristesoftware.com> wrote:
Thanks to the suggestions, I use number_format($my_number, 2) to format the number in an edit field. Now I need to reenter it into MySQL. How should I use preg_replace to remove the commas? This removes the commas *and* the decimal point: preg_replace('/\D/', '', $str) In reviewing patterns, I cannot find the purpose of the "/" character in the above. Many thanks.... Toddthe / in above is the start and end token. for every preg_* function, this is used. You could replace it by any other character as long as it is the same for start and end. so above could also be preg_replace('%\D%','',$str); I use % nearly allways, because i like it, and it isn't used a lot. / might be used in paths and can get confusing when \ also used. Tijnema