How do I, using preg_replace, replace more than one underscore with just one underscore?
Actually using /__+/ or /_{2,}/ would be better than /_+/ since a single underscore does not need to be replaced. This will improve the speed of the preg variant.
/__+/
/_{2,}/
/_+/