Possible Duplicate:
Regular expression to remove anything but alphanumeric & spaces (in PHP)
I'm trying to get
//before preg_replace -> Hi (Jimmy),
$string = preg_replace('/[^\da-z]/i', '', $string);
//after current preg_replace -> HiJimmy
//what it should be -> Hi Jimmy
preg_replace removing all alphanumeric characters, except for spaces. Is this possible?
Just add a space to your group:
$string = preg_replace('/[^\da-z ]/i', '', $string);
// ^ Notice the space here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With