note 89997 added to function.preg-match-all
| From: | (ad) | Date: | Wed, 01 Apr 2009 10:06:40 +0000 |
| Subject: | note 89997 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152691@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: 89.190.194.18
Probable Submitter: 87.121.44.186
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/89997
Del: integrated -- https://master.php.net/note/delete/89997/integrated
Del: useless -- https://master.php.net/note/delete/89997/useless
Del: bad code -- https://master.php.net/note/delete/89997/bad+code
Del: spam -- https://master.php.net/note/delete/89997/spam
Del: non-english -- https://master.php.net/note/delete/89997/non-english
Del: in docs -- https://master.php.net/note/delete/89997/in+docs
Del: other reasons-- https://master.php.net/note/delete/89997
Reject -- https://master.php.net/note/reject/89997
Search -- https://master.php.net/manage/user-notes.php