public function maxHtmlLineLength($contents, $maxHtmlLineLength)
    {
        if (strlen($contents) <= $maxHtmlLineLength) {
            return $contents;
        }

        $result = '';
        $splits = str_split($contents, $maxHtmlLineLength);
        foreach ($splits as $split) {
            $pos = strrpos($split, '><');
            if ($pos === false) {
                $result .= $split;
            } else {
                $result .= substr_replace($split, PHP_EOL, $pos + 1, 0);
            }
        }

        return $result;
    }
public function maxHtmlLineLength($contents, $maxHtmlLineLength)
    {
        if (strlen($contents) <= $maxHtmlLineLength) {
            return $contents;
        }

        $result = '';
        $splits = str_split($contents, $maxHtmlLineLength);
        foreach ($splits as $split) {
            $pos = strrpos($split, '><');
            if ($pos === false) {
                $result .= $split;
            } else {
                $result .= substr_replace($split, PHP_EOL, $pos + 1, 0);
            }
        }

        return $result;
    }
public function maxHtmlLineLength ( $ contents , $ maxHtmlLineLength ) { if ( strlen ( $ contents ) <= $ maxHtmlLineLength ) { return $ contents ; } $ result = '' ; $ splits = str_split ( $ contents , $ maxHtmlLineLength ) ; foreach ( $ splits as $ split ) { $ pos = strrpos ( $ split , '><' ) ; if ( $ pos === false ) { $ result .= $ split ; } else { $ result .= substr_replace ( $ split , PHP_EOL , $ pos + 1 , 0 ) ; } } return $ result ; }
Old browsers, firewalls and more can't handle to long lines.
Therefore add a linebreak after specified character length.

@param int    $maxHtmlLineLength
@param string $contents

@return string
Old browsers firewalls and more can t handle to long lines . Therefore add a linebreak after specified character length .