0

I need to change the ereg replace to a preg replace on this statement:

$return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));

However it errors when I make the change.

Any ideas on the fix to make this work?

KatieK
  • 13,586
  • 17
  • 76
  • 90

1 Answers1

0

like this?

  $return = trim(preg_replace('/ +/',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
Anze
  • 707
  • 9
  • 15
  • Why are you posting the same thing I answered? Even worse your example will mismatch or actually not match the blank space before the + sign. – php_nub_qq May 30 '13 at 16:20
  • sorry my connection is slow, I didn't get the update, c'mon i'm sorry buddy, you didn't need to undervote this..! calm down, and it's not exactly the same, "/ +/" is the right way, also used in the manual to express regular forms http://php.net/manual/it/function.preg-replace.php – Anze May 30 '13 at 16:24