note 90995 added to function.preg-match-all
| From: | tonicboy at osu1 dot php dot net | Date: | Wed, 20 May 2009 10:56:08 +0000 |
| Subject: | note 90995 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-155778@lists.php.net to get a copy of this message | ||
@ad
wow, that's very complex code for a simple function. why don't you just do:
$clean = preg_replace("/[^0-9()\.\- ]/", "", $phone);
i'm confused why you even want to keep any non-digit characters anyway. it's usually best
practice to store phone numbers as digits-only. also, there's no need to use the multibyte
version of strlen if you've just stripped out everything but single-byte characters. it's
a small optimization but an optimization nonetheless.
----
Server IP: 64.71.164.2
Probable Submitter: 115.75.73.30
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/90995
Del: integrated -- https://master.php.net/note/delete/90995/integrated
Del: useless -- https://master.php.net/note/delete/90995/useless
Del: bad code -- https://master.php.net/note/delete/90995/bad+code
Del: spam -- https://master.php.net/note/delete/90995/spam
Del: non-english -- https://master.php.net/note/delete/90995/non-english
Del: in docs -- https://master.php.net/note/delete/90995/in+docs
Del: other reasons-- https://master.php.net/note/delete/90995
Reject -- https://master.php.net/note/reject/90995
Search -- https://master.php.net/manage/user-notes.php