Pergunta

In my code:


$c = preg_replace('#[^a-z0-9áčďéěíňóřšťúůýž_-:().,;!?]#i', '', $_POST['c']);


I get this error:
Warning: preg_replace() [function.preg-replace]: Compilation failed: range out of order in character class at offset 40


IDK where could be the error.

Foi útil?

Solução

Do this way:

$c = preg_replace('#[^a-z0-9áčďéěíňóřšťúůýž_\-:().,;!?]#i', '', $_POST['c']);

you need to escape - inside square brackets [..] because it's treated as interval specifier

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top