match strings using ctype functions in php
by Guna[ Edit ] 2011-10-11 14:09:43
Hi,
We use preg_match in php to match the string is in particular format. There is note in php manual which says that "preg_match" funtion works slow.
But php has some inbuilt functions which works similar to preg_match concepts.
To check the given string consists only string and number we can use "
ctype_alnum" function.For example,
$word="hiox";
if(ctype_alnum($word))
echo "contains only alpha numeric characters";
else
echo "it contains non alphanumerica characters also";
There are some more ctype functions like ctype_digit etc.,