note 20661 added to ref.strings
| From: | i_hat3_s_pamers at hotmail dot com | Date: | Thu, 11 Apr 2002 17:52:08 +0000 |
| Subject: | note 20661 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29121@lists.php.net to get a copy of this message | ||
Much faster and much better way to check does string consists
from alphanumeric chars 'only' ...
By the way, author of previous isalphanumstr()
forgot to add whitespace to his array.
It's not an alphanumeric char,
but who would need this function without it ? :)
function isalphanumstr($string) {
$res=true;
for($i = 0; $i < strlen($string); $i++)
if((ord($string[$i])<48 && ord($string[$i])!=32) ||
(ord($string[$i])>57 && ord($string[$i])<65) ||
(ord($string[$i])>90 && ord($string[$i])<97) ||
ord($string[$i])>122) {$res=false; break;}
return $res;
}
echo isalphanumstr(" 1234567890qwertyuiopasdfghjklzxcvbnm
QWERTYUIOPASDFGHJKLZXCVBNM");
//... returns "1" //;)
--
http://www.php.net/manual/en/ref.strings.php
http://master.php.net/manage/user-notes.php?action=edit+20661
http://master.php.net/manage/user-notes.php?action=delete+20661
http://master.php.net/manage/user-notes.php?action=reject+20661