空格转换成下划线

@param string $str

@return mixed|string
492135
static function strfilter($str)
    {
        $str = str_replace(' ', '_', $str);

        $str = strip_tags($str);

        $str = htmlspecialchars($str);

        return $str;
    }
1149417
public static function ucFirst($str)
    {
        if (self::$use_mbstring) {
            $first = self::toUpper(self::sub($str, 0, 1));
            $str   = $first . self::sub($str, 1);
        } else {
            $str   = ucfirst($str);
        }
        
        return $str;
    }
462603
protected function escape($str)
    {
        if (is_string($str) OR (is_object($str) && method_exists($str, '__toString'))) {
            return "'".$this->escapeStr($str)."'";
        } elseif (is_bool($str)) {
            return ($str === false) ? 0 : 1;
        } elseif ($str === null) {
            return 'NULL';
        }
        return $str;
    }
1269482
public static function toSlugUnderscoreUppercase(string $str)
  {
    $clean = implode(' ', self::splitCamelCase($str));
    $clean = self::toSlug($clean);
    $clean = self::toUnderscoreSeparated($clean);
    $clean = strtoupper($clean);
    return $clean;
  }
737900
public static function str2url($str)
    {
        $str = self::rus2translit($str);
        $str = strtolower($str);
        $str = preg_replace('~[^-a-z0-9_]+~u', '-', $str);
        $str = trim($str, "-");
        return $str;
    }
1275406
public static function hump2Underline($str) {
        $arr = array();
        for( $i = 1; $i < strlen($str); $i++ ) {
            if ( ord($str[$i]) > 64 && ord($str[$i]) < 91 ) {
                $arr[] = "_".strtolower($str[$i]);
            } else {
                $arr[] = $str[$i];
            }
        }
        return implode('', $arr);
    }
1226791
public static function underscore(string $str): string
    {
        $result = preg_replace(
            [
                '/([A-Z]+)([A-Z][a-z])/',
                '/([a-z\d])([A-Z])/',
            ],
            [
                '\\1_\\2',
                '\\1_\\2',
            ],
            str_replace('_', '.', static::removeMultipleSpaces($str))
        );

        return mb_strtolower($result);
    }
1138689
private function filterQueryOrFragment(string $str): string
    {
        return \preg_replace_callback(
            '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
            [$this, 'urlEncodeChar'],
            $str
        );
    }
721852
private function _strtoupper($str)
    {
        $str = html_entity_decode($str, ENT_COMPAT, $this->charset);
        $str = mb_strtoupper($str);
        $str = htmlspecialchars($str, ENT_COMPAT, $this->charset);

        return $str;
    }
122875
public function token($str) {
        $str=trim(preg_replace('/\{\{(.+?)\}\}/s',trim('\1'),
            Base::instance()->compile($str)));
        if (preg_match('/^(.+)(?<!\|)\|((?:\h*\w+(?:\h*[,;]?))+)$/s',
            $str,$parts)) {
            $str=trim($parts[1]);
            foreach (Base::instance()->split($parts[2]) as $func)
                $str=is_string($cmd=$this->filter($func))?
                    $cmd.'('.$str.')':
                    'Base::instance()->'.
                    'call($this->filter(\''.$func.'\'),['.$str.'])';
        } elseif (false !== strpos($str, '(')) {
            for ($i=0,$len=strlen($str),$newStr='',$tmp='';$i<$len;) {
                if ($str[$i] === '(') {
                    if ($tmp && array_key_exists($tmp, $this->filter)) {
                        $tmp = $this->filter[$tmp];
                    }
                    $newStr .= $tmp . '(';
                    $tmp = '';
                } elseif (in_array($str[$i], [' '])) {
                    $newStr .= $tmp . $str[$i];
                    $tmp = '';
                } else {
                    $tmp .= $str[$i];
                }
                $i++;
            }
            $newStr .= $tmp;
            $str = $newStr;
        }

        return $str;
    }
1064022
public static function core($str)
    {
        $str = _String::normalizePunctuationSpaces($str);
        $str = mb_strtolower(trim($str));
        $str = _String::normalizeSpaces($str);
        return $str;
    }
1351774
public static function decorateTT($str)
    {
        $str = htmlspecialchars($str, ENT_QUOTES);
        $str = preg_replace('/`([^`]*)`/', '<tt>\\1</tt>', $str);

        return $str;
    }
657557
public static function last($str)
    {
        $str = str_replace('\\', '/', $str);
        $i = strrpos($str, '/');
        if ($i === false) {
            return $str;
        }

        return substr($str, ($i + 1));
    }
1110372
public static function toAscii(string $str) : string
    {
        $clean = preg_replace('/[^a-zA-Z0-9\.\/_|+ -]/', '', $str);
        $clean = strtolower(trim($clean, '-'));
        $clean = preg_replace('/[\/_|+ -]+/', '-', $clean);

        return $clean;
    }
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
966657
public static function strToHex($str)
	{
		$r = "";
		$l = strlen($str);
		for($i = 0; $i < $l; $i++)
			$r .= str_pad(strtoupper(dechex(ord($str[$i]))), 2, " ",
				STR_PAD_LEFT) . " ";
		return $r;
	}
1253387
public static function underline2hump($str) {

        $str = trim($str);
        if ( strpos($str, "_") === false ) return $str;

        $arr = explode("_", $str);
        $__str = $arr[0];
        for( $i = 1; $i < count($arr); $i++ ) {
            $__str .= ucfirst($arr[$i]);
        }
        return $__str;
    }