note 57071 added to function.preg-match

From: Date: Thu, 22 Sep 2005 18:34:52 +0000
Subject: note 57071 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-95629@lists.php.net to get a copy of this message
To check a Romanian landline phone number, and to return "Bucharest", "Proper" or "Unknown", I've used this function: <? function verify_destination($destination) { $dst_length=strlen($destination); if ($dst_length=="10"){ if(preg_match("/^021[2-7]{1}[0-9]{6}$/",$destination)) { $destination_match="Bucharest"; } elseif (preg_match("/^02[3-6]{1}[0-9]{1}[1-7]{1}[0-9]{5}$/",$destination)) { $destination_match = "Proper"; } else { $destination_match = "Unknown"; } } return ($destination_match); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57071 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57071&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57071&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95629) next »