Possible Duplicate:
PHP Preg-Replace more than one underscore
Hi, I'm just wondering how I can replace 2 or more - signs in a string with just one in PHP.
So like
1-2---3--4
would go to
1-2-3-4
Thanks :)
Possible Duplicate:
PHP Preg-Replace more than one underscore
Hi, I'm just wondering how I can replace 2 or more - signs in a string with just one in PHP.
So like
1-2---3--4
would go to
1-2-3-4
Thanks :)
No need regex
$text="1-2---3--4";
$s = implode("-",array_filter ( explode("-",$text) )) ;
print_r($s);