PHP mb_ereg_replace not replacing while preg_replace works as intended

luc79

New Member
I am trying to replace in a string all non word characters with empty string expect for spaces and the put together all multiple spaces as one single space.Following code does this.\[code\]$cleanedString = preg_replace('/[^\w]/', ' ', $name); $cleanedString = preg_replace('/\s+/', ' ', $cleanedString);\[/code\]But when I am trying to use mb_ereg_replace nothing happens. \[code\]$cleanedString = mb_ereg_replace('/[^\w]/', ' ', $name); $cleanedString = mb_ereg_replace('/\s+/', ' ', $cleanedString);\[/code\]$cleanedString is same as of that if $name in the above case. What am I doing wrong?
 
Back
Top