note 90000 added to function.preg-match-all
| From: | ad at osu1 dot php dot net | Date: | Wed, 01 Apr 2009 13:18:13 +0000 |
| Subject: | note 90000 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152699@lists.php.net to get a copy of this message | ||
i have made up a simple function to extract a number from a string..
I am not sure how good it is, but it works.
It gets only the numbers 0-9, the "-", " ", "(", ")",
"."
characters.. This is as far as I know the most widely used characters for a Phone number.
function clean_phone_number($phone) {
if (!empty($phone)) {
//var_dump($phone);
preg_match_all('/[0-9\(\)+.\- ]/s', $phone, $cleaned);
foreach($cleaned[0] as $k=>$v) {
$ready .= $v;
}
var_dump($ready);
die;
if (mb_strlen($cleaned) > 4 && mb_strlen($cleaned) <=25) {
return $cleaned;
}
else {
return false;
}
}
return false;
}
----
Server IP: 69.147.83.197
Probable Submitter: 68.82.6.9
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/90000
Del: integrated -- https://master.php.net/note/delete/90000/integrated
Del: useless -- https://master.php.net/note/delete/90000/useless
Del: bad code -- https://master.php.net/note/delete/90000/bad+code
Del: spam -- https://master.php.net/note/delete/90000/spam
Del: non-english -- https://master.php.net/note/delete/90000/non-english
Del: in docs -- https://master.php.net/note/delete/90000/in+docs
Del: other reasons-- https://master.php.net/note/delete/90000
Reject -- https://master.php.net/note/reject/90000
Search -- https://master.php.net/manage/user-notes.php