$output = preg_replace('/[^\da-z A-Z]/', '', $input);
This will remove any characters other than:
- \d (Numbers)
- a-z (Lower case characters)
- A-Z (Upper case characters)
- And spaces (There is a space between "z" and "A")
Mainly notes to future-Twig (and for anyone else who may find them useful)
If you've found one or more of my blog posts helpful, why not say thanks by buying me a coffee or beer?
$output = preg_replace('/[^\da-z A-Z]/', '', $input);
This will remove any characters other than: