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.

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top