Re: Stripping chars in string but leaving numerics
| From: | Paul Gardiner | Date: | Wed, 02 Aug 2000 09:09:12 +0000 |
| Subject: | Re: Stripping chars in string but leaving numerics | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9655@lists.php.net to get a copy of this message | ||
Hi Anders,
You could try the following:
$MyString = "abcd*()123";
$MyString = ereg_replace("[^0-9]","",$MyString);
Regards,
- Paul -
----- Original Message -----
From: "Anders Dannberg" <anders.dannberg@edk.se>
To: <php-general@lists.php.net>
Sent: Wednesday, August 02, 2000 9:01 AM
Subject: [PHP] Stripping chars in string but leaving numerics
> I need advice on how i should strip all characters in a string(including
> special chars) but leave numbers (0-9) and store this in a
> $formatted_string. Any ideas how i do this an easy way?
>
> So if i have a string with value "abcd*()123" i want the output to be
"123"
>
> Thanks in advance.
> Anders
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>