CI_Typography::nl2br_except_pre PHP Method

nl2br_except_pre() public method

Convert newlines to HTML line breaks except within PRE tags
public nl2br_except_pre ( $str ) : string
return string
    public function nl2br_except_pre($str)
    {
        $newstr = '';
        for ($ex = explode('pre>', $str), $ct = count($ex), $i = 0; $i < $ct; $i++) {
            $newstr .= $i % 2 === 0 ? nl2br($ex[$i]) : $ex[$i];
            if ($ct - 1 !== $i) {
                $newstr .= 'pre>';
            }
        }
        return $newstr;
    }