Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexchent committed Jan 16, 2020
1 parent d67665e commit 062fc4b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/.idea/vendor
.idea/vendor
Expand Down
127 changes: 0 additions & 127 deletions Cache/Redis.php

This file was deleted.

75 changes: 33 additions & 42 deletions Helper/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,36 @@ public static function getBC($zh){
return $ret;
}

/**
* 生成简码
*
* @param string $name 名称,由数字英文字母或汉字组成
*
* @return string
* @author tao.chen
*/
public static function createBC($name)
{
$bc = '';
$len = mb_strlen($name, "UTF8");
for ($i = 0; $i < $len; $i++) {
$charter = mb_substr($name, $i, 1, "UTF8");
if (preg_match("/[a-zA-Z0-9]/", $charter)) {
//匹配到是英文字母或数字,直接输入
$firstCharter = strval(strtoupper($charter));
} else {
//只接受汉字,其他返回null
$firstCharter = self::getFirstCharter($charter);
}
$bc .= $firstCharter;
}
if (empty($bc)) {
$bc = '*';
}
$bc = substr($bc, 0, 10);
return $bc;
}

/**
* 选定数组的某个值做key重组数组
* 适用于二维数组
Expand Down Expand Up @@ -265,35 +295,7 @@ public static function match_chinese($chars, $encoding = 'utf8')



/**
* 生成简码
*
* @param string $name 名称,由数字英文字母或汉字组成
*
* @return string
* @author tao.chen
*/
public static function createBC($name)
{
$bc = '';
$len = mb_strlen($name, "UTF8");
for ($i = 0; $i < $len; $i++) {
$charter = mb_substr($name, $i, 1, "UTF8");
if (preg_match("/[a-zA-Z0-9]/", $charter)) {
//匹配到是英文字母或数字,直接输入
$firstCharter = strval(strtoupper($charter));
} else {
//只接受汉字,其他返回null
$firstCharter = self::getFirstCharter($charter);
}
$bc .= $firstCharter;
}
if (empty($bc)) {
$bc = '*';
}
$bc = substr($bc, 0, 10);
return $bc;
}


public static function isNotJson($str)
{
Expand Down Expand Up @@ -328,11 +330,10 @@ public static function getRelativePath($a, $b)
$path = '';
$arr = explode('/', $a);
$brr = explode('/', $b);
// var_dump($brr);

$same = array_intersect_assoc($arr, $brr);//获取两个数组相同的部分
//var_dump($same);
$dir = array_diff_assoc($brr, $same);
// var_dump($dir);die;

for($i = 1; $i <= count($dir)-1; $i++) {
$path .='../';
}
Expand All @@ -342,14 +343,4 @@ public static function getRelativePath($a, $b)
return $path;
}


public static function getmicrotime(){
list($u,$s) = explode('', microtime());
$num = (float)$u + (float)$s;
return sprintf("%.4f", $num);

}



}
1 change: 1 addition & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php/**自动加载外部类 * * Created by PhpStorm. * User: SD * Date: 2016/7/7 * Time: 14:15 */class autoload{ public static function load($className){ $filePath = sprintf("%s.php",str_replace('\\','/',$className));//格式化字符串 if(is_file($filePath)) require_once $filePath; }}spl_autoload_register("autoload::load");
Expand Down

0 comments on commit 062fc4b

Please sign in to comment.