src/StringUtils.php
public static function pre2html($input = '', $decontaminate = true)
    {
        // O) Decontaminate
        if ($decontaminate) {
            $input = htmlentities($input);
        }
        // I) Replace line breaks.
        $input = str_replace(PHP_EOL, '<br/>', $input);
        // II) Replace space characters.
        $input = str_replace('  ', '&nbsp;&nbsp;', $input);
        // III) Replace tab characters.
        $input = str_replace("\t", '&nbsp;&nbsp;', $input);
        return $input;
    }
public static function pre2html($input = '', $decontaminate = true)
    {
        // O) Decontaminate
        if ($decontaminate) {
            $input = htmlentities($input);
        }
        // I) Replace line breaks.
        $input = str_replace(PHP_EOL, '<br/>', $input);
        // II) Replace space characters.
        $input = str_replace('  ', '&nbsp;&nbsp;', $input);
        // III) Replace tab characters.
        $input = str_replace("\t", '&nbsp;&nbsp;', $input);
        return $input;
    }
Converts preformatted text to pure html encoded text.
(Linebreaks => <br/>, Multiple spaces => n X &nbsp;)
@param  string  $input
@param  boolean $decontaminate
@return string