格式化银行卡号

@param $str
@return string
551849
public static function formatBankCard($str)
    {
        $str = (string)$str;
        preg_match('/([\d]{4})([\d]{4})([\d]{4})([\d]{4})([\d]{0,})?/', $str, $match);
        unset($match[0]);
        return implode(' ', $match);
    }
835641
static public function fromCamel($str) {
      $str[0] = strtolower($str[0]);
      return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
  }
82265
private function _strtoupper($str)
    {
        $str = html_entity_decode($str, ENT_COMPAT);

        if (function_exists('mb_strtoupper')) {
            $str = mb_strtoupper($str, 'UTF-8');
        } else {
            $str = strtoupper($str);
        }

        $str = htmlspecialchars($str, ENT_COMPAT);

        return $str;
    }
678550
public static function getBasic($str)
    {
        $r = '';
        /*
         * Split the string by line breakes.
         */
        foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) {
            /*
             * And append it with tabs and line breaks to the return var.
             */
            $r .= Generator::getTabs();
            $r .= trim($line);
            $r .= Generator::getLineBreak();
        }

        return $r;
    }
556696
public static function java_truncate(string $str): string
    {
        if (strlen($str) > 955) {
            return substr($str, 0, 475).'[...]'.substr($str, -475);
        }

        return $str;
    }
153603
public static function Format ($str = '', array $args = []) {
		foreach ($args as $key => $value) {
			$pos = strpos($str, '{'.$key.'}');
			if ($pos !== FALSE)
				$str = substr($str, 0, $pos) . $value . substr($str, $pos + strlen($key) + 2);
		}
		return $str;
	}
788735
public static function scheduleSelectTime($str)
    {
        $pattern = '/周(.*?)第([,\d]+).*?([-\d]+)周(\|(.*?)周)?/';

        $ret = [];
        if (preg_match($pattern, $str, $matches)) {
            $ret = [
                'week'         => $matches[1],
                'time_section' => $matches[2],
                'week_section' => $matches[3],
                'week_remark'  => isset($matches[5]) ? $matches[5] : '',
            ];
        }

        return $ret;
    }
1074652
protected function _code($str) {
		$self=$this;
		return preg_replace_callback(
			'/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/',
			function($expr) use($self) {
				return '<code>'.
					$self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>';
			},
			$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;
    }
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;
    }
859389
public function escape($str) {
        if (!$this->isConnected) {
            $rc = $this->createConnection();
            if ($rc === FALSE) {
                return FALSE;
            }
        }
        return $this->mysqli->real_escape_string($str);
    }
1279817
public static function getString(&$str)
    {
        $p = strpos($str, "\x00");
        if ($p === false) {
            return '';
        }
        $r   = static::binarySubstr($str, 0, $p);
        $str = static::binarySubstr($str, $p + 1);

        return $r;
    }
16520
protected function strtoupper($str)
    {
        $str = html_entity_decode($str, $this->htmlFuncFlags, self::ENCODING);
        $str = mb_strtoupper($str);
        $str = htmlspecialchars($str, $this->htmlFuncFlags, self::ENCODING);

        return $str;
    }
82468
public function widont($str) {
		$str = rtrim($str);
		$space = strrpos($str, ' ');

		if ($space !== false) {
			$str = substr($str, 0, $space) . '&nbsp;' . substr($str, $space + 1);
		}

		return $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;
	}
541557
public static function toCamelCase(string $str): string
    {
        $str = trim($str);
        $fn = function($arg) {
            list($match, $char) = $arg;
            $ret = str_replace($char, "", $match);
            return strtoupper($ret);
        };
        return preg_replace_callback("~( |_|-){1,}[A-Za-z]~", $fn, $str);
    }
923741
public function encode($str)
    {
        //是否补码
        if ($this->padding)
        {
            $str = self::PADDING_PKCS5 == $this->padding ? $this->addPKCS5Padding($str) : $this->addPKCS7Padding($str);
        }
        //是否进行BASE64编码
        if ($this->base64Encoding)
        {
            $_str = base64_encode($str);
        }
        else
        {
            $_str = $str;
        }
        return mcrypt_encrypt($this->cipher, $this->key, $_str, $this->mode, $this->iv);
    }