I feel like I can learn a lot by seeing these two regular expressions as one. Mainly selecting the space in between >
and <
while not selecting the >
and <
themselves, so I can replace it with "" rather than "><". Is there a way that these could be merged without selecting that space?
$html = preg_replace('/(
)|()/',"",$html);
$html = preg_replace('/>(\s+)</',"><",$html);