check if string contain only a-z/A-Z

Posted on 16th Feb 2014 by admin

Is where any way to check if string contains only a-z/A-Z, without writing an array with all possible letters and then looping it.

Code:
$available = array('a', 'b', 'c, 'd'); //write a-z

for ($i = 0; $i <= count($available); $i++)
{
$string = str_replace($available[$i], "", $string);
}

if ($string != "")
{
print "Illegal character.";
}

Other forums