strtolower() is not working for your Á character
á is NOT equal to strtolower("Á") in my test.
Remove your Á, and the space (like cars10 said) and it is valid.
Question
The string "Árvíztűrő tükörfúrógép" seems to be invalid. Why?
if(isValid("Árvíztűrő tükörfúrógép",true,true))echo "VALID";else echo "INVALID";
function isValid($s, $abc=false, $accent=false, $numbers=false, $etc="")
{
$valid="";
if($abc)
$valid = "abcdefghijklmnopqrstzuvwxyz";
if($accent)
$valid .= "öüóűőúéáí";
if($numbers)
$valid .= "0123456789";
$valid .= $etc;
for($i=0; $i < mb_strlen($s); $i++){
$k = false;
for($j = 0; $j < mb_strlen($valid); $j++){
if(strtolower(mb_substr($s, $i, 1)) == mb_substr($valid, $j, 1))
$k = true;
}
if(!$k)
return false;
}
return true;
}
Thanks for your help in advance!
UPDATE#1:
davebobak noticed that lowercase Á is not equal to á, but why?
Solution
strtolower() is not working for your Á character
á is NOT equal to strtolower("Á") in my test.
Remove your Á, and the space (like cars10 said) and it is valid.
OTHER TIPS
Your teststring "Árvíztűrő tükörfúrógép"
contains a blank (between ő
and t
) which is not in your list of acepted characters. Extend the $valid
-string for $abc
by this extra blank and you should be OK.