function remove_breaks($html,$max){ $html=trim(preg_replace("/(\r\n|\r|\n){".($max+1).",}/u",str_repeat("\r\n",$max),$html)); return($html); } $html=remove_breaks($html,1);