Autor Zpráva
aaa
Profil
nevim proč mi tohle nefunguje, můžete někdo pomoci? díky. pořád vypisuje že obsahuje nepovolené znaky... :(

<?

$s_string = 'nejakytexta';
$num_chars = strlen($s_string);

for($i = 0 ; $i < $num_chars ; $i++){

$string = $s_string[$i];

if($string !== ' ' or $string == 'A'
or $string == 'B'
or $string == 'C'
or $string == 'D'
or $string == 'E'
or $string == 'F'
or $string == 'G'
or $string == 'H'
or $string == 'I'
or $string == 'J'
or $string == 'K'
or $string == 'L'
or $string == 'M'
or $string == 'N'
or $string == 'U'
or $string == 'V'
or $string == 'W'
or $string == 'X'
or $string == 'Y'
or $string == 'Z'
or $string == 'a'
or $string == 'b'
or $string == 'c'
or $string == 'd'
or $string == 'e'
or $string == 'f'
or $string == 'g'
or $string == 'h'
or $string == 'i'
or $string == 'j'
or $string == 'k'
or $string == 'l'
or $string == 'm'
or $string == 'n'
or $string == 'o'
or $string == 'p'
or $string == 'q'
or $string == 'r'
or $string == 's'
or $string == 't'
or $string == 'u'
or $string == 'v'
or $string == 'w'
or $string == 'x'
or $string == 'y'
or $string == 'z'
or $string == '0'
or $string == '1'
or $string == '2'
or $string == '3'
or $string == '4'
or $string == '5'
or $string == '6'
or $string == '7'
or $string == '8'
or $string == '9'
or $string == '_'
or $string == '.'
or $string == '-'

){

$num++;

}else{

$num = 0;

}

}

if($num > 0){

echo 'retezec obsahuje nepovolene znaky';

echo $num;

}else{

echo 'retezec je v poradku';

echo $num;

}

?>
jaco
Profil
Nerozumiem, čo ten skript má vlastne robiť. A aj keby, robíš to strašne zložito, regulérne výrazy by to určite zvládli na dvoch-troch riadkoch.
Mastodont
Profil
http://www.regularnivyrazy.info/

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0