public static function toSingleWhitespace($string, $trim = true)
    {
        $string = preg_replace("/\r|\n|\t/", " ", $string);
        $string = preg_replace("/ {2,}/", " ", $string);

        if ($trim) {
            $string = self::trim($string);
        }

        return $string;
    }
public static function toSingleWhitespace($string, $trim = true)
    {
        $string = preg_replace("/\r|\n|\t/", " ", $string);
        $string = preg_replace("/ {2,}/", " ", $string);

        if ($trim) {
            $string = self::trim($string);
        }

        return $string;
    }
public static function toSingleWhitespace ( $ string , $ trim = true ) { $ string = preg_replace ( "/\r|\n|\t/" , " " , $ string ) ; $ string = preg_replace ( "/ {2,}/" , " " , $ string ) ; if ( $ trim ) { $ string = self :: trim ( $ string ) ; } return $ string ; }
Convert to single line string without multiple whitespaces.

@param string $string
@param bool   $trim [optional]

@return string
Convert to single line string without multiple whitespaces .