How can I get a string that only contains a to z, A to Z, 0 to 9 and some symbols?
Both these regexes should do it:
$str = preg_replace('~[^a-z0-9]+~i', '', $str);
Or:
$str = preg_replace('~[^a-zA-Z0-9]+~', '', $str);