Replace multiple dashes with one dash
you can use
<?php
$string="something-------another--thing";
echo $str = preg_replace('/-{2,}/','-',$string);
Output
something-another-thing
Use preg_replace
to replace a pattern.
$str = preg_replace('/-+/', '-', $str);
The regular expression -+
matches any sequence of 1 or more hyphen characters.
If you don't understand regular expressions, read the tutorial at www.regular-expression.info.