CI_Typography::nl2br_except_pre PHP Метод

nl2br_except_pre() публичный Метод

Convert newlines to HTML line breaks except within PRE tags
public nl2br_except_pre ( $str ) : string
Результат 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;
    }