note 89673 modified in function.split by danbrown

From: Date: Wed, 18 Mar 2009 17:34:27 +0000
Subject: note 89673 modified in function.split by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152108@lists.php.net to get a copy of this message
This function just makes sure there are 10 digits in a string, no matter what other characters there are. I'm using it for validating any phone number in the world and requiring an area code. It's far from perfect, but since I don't know which country the phone number is for, it's good enough for my purposes: <?php function validPhone($str) { $digits = split("[0-9]",$str); return count($digits)>10; } ?> --was-- This function just makes sure there are 10 digits in a string, no matter what other characters there are. I'm using it for validating any phone number in the world and requiring an area code. It's far from perfect, but since I don't know which country the phone number is for, it's good enough for my purposes: function validPhone($str) { $digits = split("[0-9]",$str); return count($digits)>10; } http://php.net/manual/en/function.split.php

« previous php.notes (#152108) next »