首页
关于
归档
朋友
留言
API平台
告白墙
休闲游戏
更多
留言板
练字贴
Layui手册
Search
1
【PHP】PHPoffice/PHPSpreadsheet读取和写入Excel
1,006 阅读
2
【Git】No tracked branch configured for branch master or the branch doesn't exist.
742 阅读
3
【composer】composer常用命令
487 阅读
4
【Layui】控制页面元素展示隐藏
437 阅读
5
【MySQL】MySQL触发器应用场景和使用方法
417 阅读
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
登录
Search
标签搜索
PHP
函数
方法
类
MySQL
ThinkPHP
OOP
JavaScript
Layui
Web
Linux
Array
设计模式
Git
PHPSpreadsheet
PHPoffice
排序算法
面试题
Windows
基础
小破孩
累计撰写
212
篇文章
累计收到
16
条评论
首页
栏目
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
页面
关于
归档
朋友
留言
API平台
告白墙
休闲游戏
留言板
练字贴
Layui手册
搜索到
56
篇与
的结果
2022-06-19
【PHP】PHP获取汉字首个拼音
function getFirstChar($s0) { //ord() 函数返回字符串的首个字符的 ASCII 值 $fchar = ord($s0{0}); if ($fchar >= ord("A") and $fchar <= ord("z")) return strtoupper($s0{0}); $s1 = iconv("UTF-8", "gb2312", $s0); $s2 = iconv("gb2312", "UTF-8", $s1); if ($s2 == $s0) { $s = $s1; } else { $s = $s0; } $asc = ord($s{0}) * 256 + ord($s{1}) - 65536; if ($asc >= -20319 and $asc <= -20284) return "A"; if ($asc >= -20283 and $asc <= -19776) return "B"; if ($asc >= -19775 and $asc <= -19219) return "C"; if ($asc >= -19218 and $asc <= -18711) return "D"; if ($asc >= -18710 and $asc <= -18527) return "E"; if ($asc >= -18526 and $asc <= -18240) return "F"; if ($asc >= -18239 and $asc <= -17923) return "G"; if ($asc >= -17922 and $asc <= -17418) return "I"; if ($asc >= -17417 and $asc <= -16475) return "J"; if ($asc >= -16474 and $asc <= -16213) return "K"; if ($asc >= -16212 and $asc <= -15641) return "L"; if ($asc >= -15640 and $asc <= -15166) return "M"; if ($asc >= -15165 and $asc <= -14923) return "N"; if ($asc >= -14922 and $asc <= -14915) return "O"; if ($asc >= -14914 and $asc <= -14631) return "P"; if ($asc >= -14630 and $asc <= -14150) return "Q"; if ($asc >= -14149 and $asc <= -14091) return "R"; if ($asc >= -14090 and $asc <= -13319) return "S"; if ($asc >= -13318 and $asc <= -12839) return "T"; if ($asc >= -12838 and $asc <= -12557) return "W"; if ($asc >= -12556 and $asc <= -11848) return "X"; if ($asc >= -11847 and $asc <= -11056) return "Y"; if ($asc >= -11055 and $asc <= -10247) return "Z"; return null; } function chinesePhoneticize($zh) { $ret = ""; $s1 = iconv("UTF-8", "gb2312", $zh); $s2 = iconv("gb2312", "UTF-8", $s1); if ($s2 == $zh) { $zh = $s1; } for ($i = 0; $i < strlen($zh); $i++) { $s1 = substr($zh, $i, 1); $p = ord($s1); if ($p > 160) { $s2 = substr($zh, $i++, 2); $ret .= getfirstchar($s2); } else { $ret .= $s1; } } return $ret; } echo "这是中文字符串<br/>"; echo pinyin1('这是中文字符串');
2022年06月19日
133 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP根据身份证号获取星座
<?php // 根据身份证号,自动返回对应的星座 function get_xingzuo($cid) { $cid = getIDCard($cid); if (!isIdCard($cid)) return ''; $bir = substr($cid,10,4); $month = (int)substr($bir,0,2); $day = (int)substr($bir,2); $strValue = ''; if (($month == 1 && $day >= 20) || ($month == 2 && $day <= 18)) { $strValue = "水瓶座"; } else if (($month == 2 && $day >= 19) || ($month == 3 && $day <= 20)) { $strValue = "双鱼座"; } else if (($month == 3 && $day > 20) || ($month == 4 && $day <= 19)) { $strValue = "白羊座"; } else if (($month == 4 && $day >= 20) || ($month == 5 && $day <= 20)) { $strValue = "金牛座"; } else if (($month == 5 && $day >= 21) || ($month == 6 && $day <= 21)) { $strValue = "双子座"; } else if (($month == 6 && $day > 21) || ($month == 7 && $day <= 22)) { $strValue = "巨蟹座"; } else if (($month == 7 && $day > 22) || ($month == 8 && $day <= 22)) { $strValue = "狮子座"; } else if (($month == 8 && $day >= 23) || ($month == 9 && $day <= 22)) { $strValue = "处女座"; } else if (($month == 9 && $day >= 23) || ($month == 10 && $day <= 23)) { $strValue = "天秤座"; } else if (($month == 10 && $day > 23) || ($month == 11 && $day <= 22)) { $strValue = "天蝎座"; } else if (($month == 11 && $day > 22) || ($month == 12 && $day <= 21)) { $strValue = "射手座"; } else if (($month == 12 && $day > 21) || ($month == 1 && $day <= 19)) { $strValue = "魔羯座"; } return $strValue; } // 根据身份证号,自动返回对应的生肖 function get_shengxiao($cid) { $cid = getIDCard($cid); if (!isIdCard($cid)) return ''; $start = 1901; $end = $end = (int)substr($cid,6,4); $x = ($start - $end) % 12; $value = ""; if ($x == 1 || $x == -11) {$value = "鼠";} if ($x == 0) { $value = "牛";} if ($x == 11 || $x == -1) {$value = "虎";} if ($x == 10 || $x == -2) {$value = "兔";} if ($x == 9 || $x == -3) {$value = "龙";} if ($x == 8 || $x == -4) {$value = "蛇";} if ($x == 7 || $x == -5) {$value = "马";} if ($x == 6 || $x == -6) {$value = "羊";} if ($x == 5 || $x == -7) {$value = "猴";} if ($x == 4 || $x == -8) {$value = "鸡";} if ($x == 3 || $x == -9) {$value = "狗";} if ($x == 2 || $x == -10) {$value = "猪";} return $value; } function get_xingbie($cid,$comm=0) { //根据身份证号,自动返回性别 $cid = getIDCard($cid); if (!isIdCard($cid)) return ''; $sexint = (int)substr($cid,16,1); if($comm >0){ return $sexint % 2 === 0 ? '女士' : '先生'; }else{ return $sexint % 2 === 0 ? '女' : '男'; } } // 功能:把15位身份证转换成18位 function getIDCard($idCard) { // 若是15位,则转换成18位;否则直接返回ID if (15 == strlen ( $idCard )) { $W = array (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1 ); $A = array ("1","0","X","9","8","7","6","5","4","3","2" ); $s = 0; $idCard18 = substr ( $idCard, 0, 6 ) . "19" . substr ( $idCard, 6 ); $idCard18_len = strlen ( $idCard18 ); for($i = 0; $i < $idCard18_len; $i ++) { $s = $s + substr ( $idCard18, $i, 1 ) * $W [$i]; } $idCard18 .= $A [$s % 11]; return $idCard18; } else { return $idCard; } } ?>
2022年06月19日
102 阅读
0 评论
0 点赞
2022-06-19
【PHP】数据校验规则
/** * @name: check_data * @description: 检测数据规则 * @param: string 被检测的原字符串 * @param: string 被检测的类型 * @return: boolean * @create: 2014-10-10 **/ function check_data($string, $type='email'){ $return = FALSE; switch($type){ case 'email' : {$return = preg_match("/^(\w+[-+.]*\w+)*@(\w+([-.]*\w+)*\.\w+([-.]*\w+)*)$/", $string); break;} case 'http' : {$return = preg_match("/^http:\/\/[A-Za-z0-9-]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"])*$/", $string); break;} case 'qq' : {$return = preg_match("/^[1-9]\d{4,11}$/", $string); break;} case 'post' : {$return = preg_match("/^[1-9]\d{5}$/", $string); break;} case 'idnum' : {$return = preg_match("/^\d{15}(\d{2}[A-Za-z0-9])?$/", $string); break;} case 'china' : {$return = preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $string); break;} //GBK中文 case 'english' : {$return = preg_match("/^[A-Za-z]+$/", $string); break;} case 'mobile' : {$return = preg_match("/^((\(\d{3}\))|(\d{3}\-))?((13)|(14)|(15)|(17)|(18)){1}\d{9}$/", $string); break;} case 'phone' : {$return = preg_match("/^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/", $string); break;} case 'safe' : {$return = preg_match("/^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/", $string) != 0 ? TRUE : FALSE; break;} case 'age' : {$return = (preg_match("/^(-{0,1}|\+{0,1})[0-9]+(\.{0,1}[0-9]+)$/", $string) && intval($string) <= 130 && intval($string) >= 12) ? TRUE : FALSE; break;} case 'eng_num' : {$return = preg_match("/^[A-Za-z0-9]+$/", $string); break;} case 'password' : {$return = (preg_match("/^[A-Za-z0-9]+$/", $string) && strlen($string) <= 32 && strlen($string) >= 6) ? TRUE : FALSE; break;} case 'datetime' : {$return = preg_match('/^[\d]{4}-[\d]{1,2}-[\d]{1,2}\s[\d]{1,2}:[\d]{1,2}:[\d]{1,2}$/', $string); break;} case 'datetimes' : {$return = preg_match('/^[\d]{4}-[\d]{2}-[\d]{2}\s[\d]{2}:[\d]{2}:[\d]{2}$/', $string); break;} case 'date' : {$return = preg_match('/^[\d]{4}-[\d]{1,2}-[\d]{1,2}$/', $string); break;} case 'dates' : {$return = preg_match('/^[\d]{4}-[\d]{2}-[\d]{2}$/', $string); break;} case 'time' : {$return = preg_match('/^[\d]{1,2}:[\d]{1,2}:[\d]{1,2}$/', $string); break;} case 'times' : {$return = preg_match('/^[\d]{2}:[\d]{2}:[\d]{2}$/', $string); break;} case 'ip' : {$return = preg_match("/^\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b$/", $string); break;} case 'incchinese' : {$return = preg_match('/[\x{4e00}-\x{9fa5}]+/u', $string); break;} //是否包含中文 case 'plusnum' : {$return = preg_match('/^[1-9]*[1-9][0-9]*$/', $string); break;} //是否是正整数 case 'hostrecord' : {$return = preg_match('/^[A-Z_a-z0-9][A-Za-z0-9-]+(\.[A-Za-z0-9-_]+)*$/', $string); break;} //正确的主机记录,english case 'cnhostrecord' : {$return = preg_match('/^[_a-zA-Z0-9]*([\x{4e00}-\x{9fa5}]*[-a-zA-Z0-9\.]*)+[a-zA-Z0-9_]$/iu', $string); break;} //正确的主机记录,english chinese case 'domain' : {$return = preg_match('/^[A-Za-z0-9][A-Za-z0-9-]+(\.[A-Za-z0-9-]+){1,3}$/', $string); break;} //是否是域名 case 'cndomain' : {$return = (preg_match('/[\x{4e00}-\x{9fa5}]+/u', $string) && preg_match('/^([-a-zA-Z0-9\.]*[\x{4e00}-\x{9fa5}]*[-a-zA-Z0-9\.]*)+\.(中国|公司|网络|CN|COM|NET)$/iu', $string)) ? TRUE : FALSE; break;} //是否中文域名 case 'mac' : {$return = preg_match('/^[a-fA-F\d]{2}:[a-fA-F\d]{2}:[a-fA-F\d]{2}:[a-fA-F\d]{2}:[a-fA-F\d]{2}:[a-fA-F\d]{2}$/', $string); break;} case 'ipv6' : {$return = preg_match('/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/', $string); break;} } gettype($return) == 'integer' && $return = $return == 0 ? FALSE : TRUE; return $return; }
2022年06月19日
129 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP检测浏览器语言
如果你的网站上有多种语言,那么可以使用这段代码 作为默认的语言来检测浏览器语言。该段代码将返回 浏览器客户端使用的初始语言。 function get_client_language($availableLanguages, $default='en'){ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($langs as $value){ $choice=substr($value,0,2); if(in_array($choice, $availableLanguages)){ return $choice; } } } return $default; }
2022年06月19日
96 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP实现字符串截取,支持中文和其他编码
<?php /** * 字符串截取,支持中文和其他编码 * @param [string] $str [字符串] * @param integer $start [起始位置] * @param integer $length [截取长度] * @param string $charset [字符串编码] * @param boolean $suffix [是否有省略号] * @return [type] [description] */ function msubstr($str, $start=0, $length=15, $charset="utf-8", $suffix=true) { if(function_exists("mb_substr")) { return mb_substr($str, $start, $length, $charset); } elseif(function_exists('iconv_substr')) { return iconv_substr($str,$start,$length,$charset); } $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; preg_match_all($re[$charset], $str, $match); $slice = join("",array_slice($match[0], $start, $length)); if($suffix) { return $slice."…"; } return $slice; } /* 这里的关键,$charset="utf-8",对中文支持是很重要的!不然出现一些?号,就要挨批了! 使用方法如下: echo msubstr($str, $start=0, $length=15, $charset="utf-8", $suffix=true) /*
2022年06月19日
105 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP实现中文转拼音
<?php /** * PHP 汉字转拼音 * @author Jerryli(hzjerry@gmail.com) * @version V0.20140715 * @package SPFW.core.lib.final * @global SEA_PHP_FW_VAR_ENV * @example * echo CUtf8_PY::encode('阿里巴巴科技有限公司'); //编码为拼音首字母 * echo CUtf8_PY::encode('阿里巴巴科技有限公司', 'all'); //编码为全拼音 */ class CUtf8_PY { /** * 拼音字符转换图 * @var array */ private static $_aMaps = array( 'a'=>-20319,'ai'=>-20317,'an'=>-20304,'ang'=>-20295,'ao'=>-20292, 'ba'=>-20283,'bai'=>-20265,'ban'=>-20257,'bang'=>-20242,'bao'=>-20230,'bei'=>-20051,'ben'=>-20036,'beng'=>-20032,'bi'=>-20026,'bian'=>-20002,'biao'=>-19990,'bie'=>-19986,'bin'=>-19982,'bing'=>-19976,'bo'=>-19805,'bu'=>-19784, 'ca'=>-19775,'cai'=>-19774,'can'=>-19763,'cang'=>-19756,'cao'=>-19751,'ce'=>-19746,'ceng'=>-19741,'cha'=>-19739,'chai'=>-19728,'chan'=>-19725,'chang'=>-19715,'chao'=>-19540,'che'=>-19531,'chen'=>-19525,'cheng'=>-19515,'chi'=>-19500,'chong'=>-19484,'chou'=>-19479,'chu'=>-19467,'chuai'=>-19289,'chuan'=>-19288,'chuang'=>-19281,'chui'=>-19275,'chun'=>-19270,'chuo'=>-19263,'ci'=>-19261,'cong'=>-19249,'cou'=>-19243,'cu'=>-19242,'cuan'=>-19238,'cui'=>-19235,'cun'=>-19227,'cuo'=>-19224, 'da'=>-19218,'dai'=>-19212,'dan'=>-19038,'dang'=>-19023,'dao'=>-19018,'de'=>-19006,'deng'=>-19003,'di'=>-18996,'dian'=>-18977,'diao'=>-18961,'die'=>-18952,'ding'=>-18783,'diu'=>-18774,'dong'=>-18773,'dou'=>-18763,'du'=>-18756,'duan'=>-18741,'dui'=>-18735,'dun'=>-18731,'duo'=>-18722, 'e'=>-18710,'en'=>-18697,'er'=>-18696, 'fa'=>-18526,'fan'=>-18518,'fang'=>-18501,'fei'=>-18490,'fen'=>-18478,'feng'=>-18463,'fo'=>-18448,'fou'=>-18447,'fu'=>-18446, 'ga'=>-18239,'gai'=>-18237,'gan'=>-18231,'gang'=>-18220,'gao'=>-18211,'ge'=>-18201,'gei'=>-18184,'gen'=>-18183,'geng'=>-18181,'gong'=>-18012,'gou'=>-17997,'gu'=>-17988,'gua'=>-17970,'guai'=>-17964,'guan'=>-17961,'guang'=>-17950,'gui'=>-17947,'gun'=>-17931,'guo'=>-17928, 'ha'=>-17922,'hai'=>-17759,'han'=>-17752,'hang'=>-17733,'hao'=>-17730,'he'=>-17721,'hei'=>-17703,'hen'=>-17701,'heng'=>-17697,'hong'=>-17692,'hou'=>-17683,'hu'=>-17676,'hua'=>-17496,'huai'=>-17487,'huan'=>-17482,'huang'=>-17468,'hui'=>-17454,'hun'=>-17433,'huo'=>-17427, 'ji'=>-17417,'jia'=>-17202,'jian'=>-17185,'jiang'=>-16983,'jiao'=>-16970,'jie'=>-16942,'jin'=>-16915,'jing'=>-16733,'jiong'=>-16708,'jiu'=>-16706,'ju'=>-16689,'juan'=>-16664,'jue'=>-16657,'jun'=>-16647, 'ka'=>-16474,'kai'=>-16470,'kan'=>-16465,'kang'=>-16459,'kao'=>-16452,'ke'=>-16448,'ken'=>-16433,'keng'=>-16429,'kong'=>-16427,'kou'=>-16423,'ku'=>-16419,'kua'=>-16412,'kuai'=>-16407,'kuan'=>-16403,'kuang'=>-16401,'kui'=>-16393,'kun'=>-16220,'kuo'=>-16216, 'la'=>-16212,'lai'=>-16205,'lan'=>-16202,'lang'=>-16187,'lao'=>-16180,'le'=>-16171,'lei'=>-16169,'leng'=>-16158,'li'=>-16155,'lia'=>-15959,'lian'=>-15958,'liang'=>-15944,'liao'=>-15933,'lie'=>-15920,'lin'=>-15915,'ling'=>-15903,'liu'=>-15889,'long'=>-15878,'lou'=>-15707,'lu'=>-15701,'lv'=>-15681,'luan'=>-15667,'lue'=>-15661,'lun'=>-15659,'luo'=>-15652, 'ma'=>-15640,'mai'=>-15631,'man'=>-15625,'mang'=>-15454,'mao'=>-15448,'me'=>-15436,'mei'=>-15435,'men'=>-15419,'meng'=>-15416,'mi'=>-15408,'mian'=>-15394,'miao'=>-15385,'mie'=>-15377,'min'=>-15375,'ming'=>-15369,'miu'=>-15363,'mo'=>-15362,'mou'=>-15183,'mu'=>-15180, 'na'=>-15165,'nai'=>-15158,'nan'=>-15153,'nang'=>-15150,'nao'=>-15149,'ne'=>-15144,'nei'=>-15143,'nen'=>-15141,'neng'=>-15140,'ni'=>-15139,'nian'=>-15128,'niang'=>-15121,'niao'=>-15119,'nie'=>-15117,'nin'=>-15110,'ning'=>-15109,'niu'=>-14941,'nong'=>-14937,'nu'=>-14933,'nv'=>-14930,'nuan'=>-14929,'nue'=>-14928,'nuo'=>-14926, 'o'=>-14922,'ou'=>-14921, 'pa'=>-14914,'pai'=>-14908,'pan'=>-14902,'pang'=>-14894,'pao'=>-14889,'pei'=>-14882,'pen'=>-14873,'peng'=>-14871,'pi'=>-14857,'pian'=>-14678,'piao'=>-14674,'pie'=>-14670,'pin'=>-14668,'ping'=>-14663,'po'=>-14654,'pu'=>-14645, 'qi'=>-14630,'qia'=>-14594,'qian'=>-14429,'qiang'=>-14407,'qiao'=>-14399,'qie'=>-14384,'qin'=>-14379,'qing'=>-14368,'qiong'=>-14355,'qiu'=>-14353,'qu'=>-14345,'quan'=>-14170,'que'=>-14159,'qun'=>-14151, 'ran'=>-14149,'rang'=>-14145,'rao'=>-14140,'re'=>-14137,'ren'=>-14135,'reng'=>-14125,'ri'=>-14123,'rong'=>-14122,'rou'=>-14112,'ru'=>-14109,'ruan'=>-14099,'rui'=>-14097,'run'=>-14094,'ruo'=>-14092, 'sa'=>-14090,'sai'=>-14087,'san'=>-14083,'sang'=>-13917,'sao'=>-13914,'se'=>-13910,'sen'=>-13907,'seng'=>-13906,'sha'=>-13905,'shai'=>-13896,'shan'=>-13894,'shang'=>-13878,'shao'=>-13870,'she'=>-13859,'shen'=>-13847,'sheng'=>-13831,'shi'=>-13658,'shou'=>-13611,'shu'=>-13601,'shua'=>-13406,'shuai'=>-13404,'shuan'=>-13400,'shuang'=>-13398,'shui'=>-13395,'shun'=>-13391,'shuo'=>-13387,'si'=>-13383,'song'=>-13367,'sou'=>-13359,'su'=>-13356,'suan'=>-13343,'sui'=>-13340,'sun'=>-13329,'suo'=>-13326, 'ta'=>-13318,'tai'=>-13147,'tan'=>-13138,'tang'=>-13120,'tao'=>-13107,'te'=>-13096,'teng'=>-13095,'ti'=>-13091,'tian'=>-13076,'tiao'=>-13068,'tie'=>-13063,'ting'=>-13060,'tong'=>-12888,'tou'=>-12875,'tu'=>-12871,'tuan'=>-12860,'tui'=>-12858,'tun'=>-12852,'tuo'=>-12849, 'wa'=>-12838,'wai'=>-12831,'wan'=>-12829,'wang'=>-12812,'wei'=>-12802,'wen'=>-12607,'weng'=>-12597,'wo'=>-12594,'wu'=>-12585, 'xi'=>-12556,'xia'=>-12359,'xian'=>-12346,'xiang'=>-12320,'xiao'=>-12300,'xie'=>-12120,'xin'=>-12099,'xing'=>-12089,'xiong'=>-12074,'xiu'=>-12067,'xu'=>-12058,'xuan'=>-12039,'xue'=>-11867,'xun'=>-11861, 'ya'=>-11847,'yan'=>-11831,'yang'=>-11798,'yao'=>-11781,'ye'=>-11604,'yi'=>-11589,'yin'=>-11536,'ying'=>-11358,'yo'=>-11340,'yong'=>-11339,'you'=>-11324,'yu'=>-11303,'yuan'=>-11097,'yue'=>-11077,'yun'=>-11067, 'za'=>-11055,'zai'=>-11052,'zan'=>-11045,'zang'=>-11041,'zao'=>-11038,'ze'=>-11024,'zei'=>-11020,'zen'=>-11019,'zeng'=>-11018,'zha'=>-11014,'zhai'=>-10838,'zhan'=>-10832,'zhang'=>-10815,'zhao'=>-10800,'zhe'=>-10790,'zhen'=>-10780,'zheng'=>-10764,'zhi'=>-10587,'zhong'=>-10544,'zhou'=>-10533,'zhu'=>-10519,'zhua'=>-10331,'zhuai'=>-10329,'zhuan'=>-10328,'zhuang'=>-10322,'zhui'=>-10315,'zhun'=>-10309,'zhuo'=>-10307,'zi'=>-10296,'zong'=>-10281,'zou'=>-10274,'zu'=>-10270,'zuan'=>-10262,'zui'=>-10260,'zun'=>-10256,'zuo'=>-10254 ); /** * 将中文编码成拼音 * @param string $utf8Data utf8字符集数据 * @param string $sRetFormat 返回格式 [head:首字母|all:全拼音] * @return string */ public static function encode($utf8Data, $sRetFormat='head'){ $sGBK = iconv('UTF-8', 'GBK', $utf8Data); $aBuf = array(); for ($i=0, $iLoop=strlen($sGBK); $i<$iLoop; $i++) { $iChr = ord($sGBK{$i}); if ($iChr>160) $iChr = ($iChr<<8) + ord($sGBK{++$i}) - 65536; if ('head' === $sRetFormat) $aBuf[] = substr(self::zh2py($iChr),0,1); else $aBuf[] = self::zh2py($iChr); } if ('head' === $sRetFormat) return implode('', $aBuf); else return implode(' ', $aBuf); } /** * 中文转换到拼音(每次处理一个字符) * @param number $iWORD 待处理字符双字节 * @return string 拼音 */ private static function zh2py($iWORD) { if($iWORD>0 && $iWORD<160 ) { return chr($iWORD); } elseif ($iWORD<-20319||$iWORD>-10247) { return ''; } else { foreach (self::$_aMaps as $py => $code) { if($code > $iWORD) break; $result = $py; } return $result; } } } ?>
2022年06月19日
116 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP身份证验证类
<?php /** *身份证号处理函数 */ /** * 功能:根据身份证号,自动返回生日 * @param stirng $IDCard 身份证号 * @return Ambigous <string, NULL> */ function getBrithday ($idCard) { if (strlen($idCard) == 18) { $birthday = substr($idCard, 6, 4) . '-' . substr($idCard, 10, 2) . '-' . substr($idCard, 12, 2); } elseif (strlen($idCard) == 15) { $birthday = "19" . substr($idCard, 6, 2) . '-' . substr($idCard, 8, 2) . '-' . substr($idCard, 10, 2); } else { $birthday = null; } return $birthday; } /** * 功能:根据身份证号,自动返回性别 * @param string $cid 身份证号 * @param number $comm 返回的性别类型 * @return string 男/女 1/0 */ function getSex ($cid, $comm = 0) { $cid = getIDCard($cid); $sexint = (int) substr($cid, 16, 1); if ($comm > 0) { return $sexint % 2 === 0 ? '女' : '男'; } else { return $sexint % 2 === 0 ? '0' : '1'; } } /** * 功能:把15位身份证转换成18位 * @param string $idCard * @return newid or id */ function getIDCard ($idCard) { // 若是15位,则转换成18位;否则直接返回ID if (15 == strlen($idCard)) { $w = array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1); $a = array("1","0","X","9","8","7","6","5","4","3","2"); $s = 0; $idCard18 = substr($idCard, 0, 6) . "19" . substr($idCard, 6); $idCard18_len = strlen($idCard18); for ($i = 0; $i < $idCard18_len; $i ++) { $s = $s + substr($idCard18, $i, 1) * $w[$i]; } return $idCard18.$a[$s % 11]; } else { return $idCard; } } /** * 根据身份证号返回年龄 * @param string $id 身份证号 * @return string|number */ function getAge($id){ //过了这年的生日才算多了1周岁 if(empty($id)) return ''; $date=strtotime(substr($id,6,8)); //获得出生年月日的时间戳 $today=strtotime('today'); //获得今日的时间戳 $diff=floor(($today-$date)/86400/365); //得到两个日期相差的大体年数 //strtotime加上这个年数后得到那日的时间戳后与今日的时间戳相比 $age=strtotime(substr($id,6,8).' +'.$diff.'years')>$today?($diff+1):$diff; return $age; }
2022年06月19日
145 阅读
0 评论
0 点赞
2022-06-19
【PHP】PHP接口返回数据格式
/** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2020/9/30 16:35 * @param $code 状态码 * @param string $msg 提示信息 * @param array $data 数据 * @Description:返回标格式 */ function returnResponse ($code,$msg = '',$data=array()){ $retData = array( 'code' => $code, 'message' => $msg, 'data' => $data?$data:'', ); #错误时不显示data if($code != 200){ unset($retData['data']); } header('Content-Type:application/json; charset=utf-8'); exit(json_encode($retData,JSON_UNESCAPED_UNICODE)); } public function show($code = '', $message = '', $result = '', $httpCode = 200){ $data = [ 'code' => $code, 'message' => $message, 'result' => $result, ]; if(empty($data['result'])){ unset($data['result']); } return json($data,$httpCode); }这个方法只是code值在200的时候才会有返回data;
2022年06月19日
84 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP函数大全
PHP函数大全有道云地址:http://note.youdao.com/noteshare?id=f1271100f4366b0338e9a45b8bbd4db7&sub=0DA577EC658B4923A67FA4EB862D2FDA
2022年06月17日
110 阅读
0 评论
0 点赞
2022-06-17
【PHP】TP5.1框架获取服务器信息
//获取服务器相关信息 $info = [ '操作系统'=>PHP_OS, '运行环境'=>$_SERVER["SERVER_SOFTWARE"], 'PHP运行方式'=>php_sapi_name(), 'ThinkPHP版本'=> 'V'. \think\facade\App::version(), '上传附件限制'=>ini_get('upload_max_filesize'), '执行时间限制'=>ini_get('max_execution_time').'秒', '服务器时间'=>date("Y年n月j日 H:i:s"), '北京时间'=>gmdate("Y年n月j日 H:i:s",time()+8*3600), '服务器所处时区' => date_default_timezone_get(), '服务器域名/IP'=>$_SERVER['SERVER_NAME'].' [ '.gethostbyname($_SERVER['SERVER_NAME']).' ]', '剩余空间'=>round((disk_free_space(".")/(1024*1024)),2).'M', 'register_globals'=>get_cfg_var("register_globals")=="1" ? "ON" : "OFF", 'magic_quotes_gpc'=>(1===get_magic_quotes_gpc())?'YES':'NO', 'magic_quotes_runtime'=>(1===get_magic_quotes_runtime())?'YES':'NO' ]; /** * 获取当前的运行环境 * @return string */ function getHuanjing(){ switch (PHP_SAPI){ case 'fpm-fcgi': return 'nginx+php-fpm'; break; case 'cgi-fcgi': return 'nginx+fastcgi'; break; case 'apache2handler': return 'apache'; break; default: return PHP_SAPI; } } /** * 获取数据库版本 */ function dbVersion(){ $db = think\Db::query('select VERSION()'); return $db[0]['VERSION()']; } /** * 获取最大上传文件大小 */ function get_upload_max_filesize(){ return ini_get('upload_max_filesize'); }
2022年06月17日
195 阅读
1 评论
0 点赞
2022-06-17
【PHP】PHP实现阿拉伯数字转化为大写汉字
class Num2Cny{ static $basical = array(0 => "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); static $advanced = array(1 => "拾", "佰", "仟"); public static function ParseNumber($number){ $number = trim($number); if ($number > 999999999999) return "数字太大,无法处理。抱歉!"; if ($number == 0) return "零"; if (strpos($number, '.')) { $number = round($number, 2); $data = explode(".", $number); $data[0] = self::int($data[0]); $data[1] = self::dec($data[1]); return $data[0] . $data[1]; } else { return self::int($number) . '整'; } } public static function int($number){ $arr = array_reverse(str_split($number)); $data = ''; $zero = false; $zero_num = 0; foreach ($arr as $k => $v) { $_chinese = ''; $zero = ($v == 0) ? true : false; $x = $k % 4; if ($x && $zero && $zero_num > 1) continue; switch ($x) { case 0: if ($zero) { $zero_num = 0; } else { $_chinese = self::$basical[$v]; $zero_num = 1; } if ($k == 8) { $_chinese .= '亿'; } elseif ($k == 4) { $_chinese .= '万'; } break; default: if ($zero) { if ($zero_num == 1) { $_chinese = self::$basical[$v]; $zero_num++; } } else { $_chinese = self::$basical[$v]; $_chinese .= self::$advanced[$x]; } } $data = $_chinese . $data; } return $data . '元'; } public static function dec($number){ if (strlen($number) < 2) $number .= '0'; $arr = array_reverse(str_split($number)); $data = ''; $zero_num = false; foreach ($arr as $k => $v) { $zero = ($v == 0) ? true : false; $_chinese = ''; if ($k == 0) { if (!$zero) { $_chinese = self::$basical[$v]; $_chinese .= '分'; $zero_num = true; } } else { if ($zero) { if ($zero_num) { $_chinese = self::$basical[$v]; } } else { $_chinese = self::$basical[$v]; $_chinese .= '角'; } } $data = $_chinese . $data; } return $data; } } 使用方法 Num2Cny::ParseNumber($number); 注意:命名空间,访问方法,接受的$number数据验证
2022年06月17日
139 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP实现表格转换成数组
/** * @Author:小破孩 * @Time:2020/07/20 11:42 * @param $table 表格html代码 * @return mixed * @Description: 表格转数组 */ function tableArr($table){ $table = preg_replace("'<table[^>]*?>'si", "", $table); $table = preg_replace("'<tr[^>]*?>'si", "", $table); $table = preg_replace("'<td[^>]*?>'si", "", $table); $table = str_replace("</tr>", "{tr}", $table); $table = str_replace("</td>", "{td}", $table); //去掉 HTML 标记 $table = preg_replace("'<[/!]*?[^<>]*?>'si", "", $table); //去掉空白字符 $table = preg_replace("'([rn])[s]+'", "", $table); $table = preg_replace('/ /', "", $table); $table = str_replace(" ", "", $table); $table = str_replace(" ", "", $table); $table = explode('{tr}', $table); array_pop($table); foreach ($table as $key => $tr) { $td = explode('{td}', $tr); array_pop($td); $td_array[] = $td; } return $td_array; }
2022年06月17日
169 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP实现加密和解密
/** * @Author:小破孩 * @Time: 2020/7/21 16:51 * @param $txt 加密的文本 * @param string $key * @return string * @Description:加密 */ function lock_url($txt,$key='abcd'){ $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $nh = rand(0,64); $ch = $chars[$nh]; $mdKey = md5($key.$ch); $mdKey = substr($mdKey,$nh%8, $nh%8+7); $txt = base64_encode($txt); $tmp = ''; $i=0;$j=0;$k = 0; for ($i=0; $i<strlen($txt); $i++) { $k = $k == strlen($mdKey) ? 0 : $k; $j = ($nh+strpos($chars,$txt[$i])+ord($mdKey[$k++]))%64; $tmp .= $chars[$j]; } return urlencode($ch.$tmp); } /** * @Author:小破孩 * @Time: 2020/7/21 16:51 * @param $txt 解密的文本 * @param string $key * @return false|string * @Description:解密 */ function unlock_url($txt,$key='abcd'){ $txt = urldecode($txt); $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $ch = $txt[0]; $nh = strpos($chars,$ch); $mdKey = md5($key.$ch); $mdKey = substr($mdKey,$nh%8, $nh%8+7); $txt = substr($txt,1); $tmp = ''; $i=0;$j=0; $k = 0; for ($i=0; $i<strlen($txt); $i++) { $k = $k == strlen($mdKey) ? 0 : $k; $j = strpos($chars,$txt[$i])-$nh - ord($mdKey[$k++]); while ($j<0) $j+=64; $tmp .= $chars[$j]; } return base64_decode($tmp); } 更新/** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2021/3/26 17:59 * @param string $key * @param $string * @return string * @Description:加密 */ public function encryption($txt,$key='sflksdfpds456f4s4f9sd4fsd54fs9847d4ds4sd4fs'){ $txt = $txt.$key; $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $nh = rand(0,64); $ch = $chars[$nh]; $mdKey = md5($key.$ch); $mdKey = substr($mdKey,$nh%8, $nh%8+7); $txt = base64_encode($txt); $tmp = ''; $i=0;$j=0;$k = 0; for ($i=0; $i<strlen($txt); $i++) { $k = $k == strlen($mdKey) ? 0 : $k; $j = ($nh+strpos($chars,$txt[$i])+ord($mdKey[$k++]))%64; $tmp .= $chars[$j]; } return urlencode(base64_encode($ch.$tmp)); } /** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2021/3/26 17:59 * @param string $key * @param $string * @return string * @Description:解密 */ public function decryption($txt,$key='sflksdfpds456f4s4f9sd4fsd54fs9847d4ds4sd4fs'){ $txt = base64_decode(urldecode($txt)); $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $ch = $txt[0]; $nh = strpos($chars,$ch); $mdKey = md5($key.$ch); $mdKey = substr($mdKey,$nh%8, $nh%8+7); $txt = substr($txt,1); $tmp = ''; $i=0;$j=0; $k = 0; for ($i=0; $i<strlen($txt); $i++) { $k = $k == strlen($mdKey) ? 0 : $k; $j = strpos($chars,$txt[$i])-$nh - ord($mdKey[$k++]); while ($j<0) $j+=64; $tmp .= $chars[$j]; } return trim(base64_decode($tmp),$key); } 更新/** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2021/3/29 10:10 * @param $string * @param string $operation * @param string $key * @return false|string|string[] * @Description:函数encrypt($string,$operation,$key)中$string:需要加密解密的字符串;$operation:判断是加密还是解密,E表示加密,D表示解密;$key:密匙。 */ public function encryption($string,$operation = 'E',$key='sflksdfpds456f4s4f9sd4fsd54fs9847d4ds4sd4fs'){ $key=md5($key); $key_length=strlen($key); $string=$operation=='D'?base64_decode($string):substr(md5($string.$key),0,8).$string; $string_length=strlen($string); $rndkey=$box=array(); $result=''; for($i=0;$i<=255;$i++){ $rndkey[$i]=ord($key[$i%$key_length]); $box[$i]=$i; } for($j=$i=0;$i<256;$i++){ $j=($j+$box[$i]+$rndkey[$i])%256; $tmp=$box[$i]; $box[$i]=$box[$j]; $box[$j]=$tmp; } for($a=$j=$i=0;$i<$string_length;$i++){ $a=($a+1)%256; $j=($j+$box[$a])%256; $tmp=$box[$a]; $box[$a]=$box[$j]; $box[$j]=$tmp; $result.=chr(ord($string[$i])^($box[($box[$a]+$box[$j])%256])); } if($operation=='D'){ if(substr($result,0,8)==substr(md5(substr($result,8).$key),0,8)){ return substr($result,8); }else{ return''; } }else{ return str_replace('=','',base64_encode($result)); } } 更新/** * @Author: 小破孩嫩 * @Email: 3584685883@qq.com * @Time: 2021/3/29 10:11 * @param $string 字符串,明文或密文; * @param string $operation DECODE表示解密,其它表示加密; * @param string $key 密匙; * @param int $expiry 密文有效期 * @return false|string * @Description:非常给力的authcode加密函数,Discuz!经典代码(带详解) */ public function encryption($string, $operation = 'DECODE', $key = 'sflksdfpds456f4s4f9sd4fsd54fs9847d4ds4sd4fs', $expiry = 0) { // 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙 $ckey_length = 4; // 密匙 $key = md5($key ? $key : $GLOBALS['discuz_auth_key']); // 密匙a会参与加解密 $keya = md5(substr($key, 0, 16)); // 密匙b会用来做数据完整性验证 $keyb = md5(substr($key, 16, 16)); // 密匙c用于变化生成的密文 $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; // 参与运算的密匙 $cryptkey = $keya.md5($keya.$keyc); $key_length = strlen($cryptkey); // 明文,前10位用来保存时间戳,解密时验证数据有效性,10到26位用来保存$keyb(密匙b), //解密时会通过这个密匙验证数据完整性 // 如果是解码的话,会从第$ckey_length位开始,因为密文前$ckey_length位保存 动态密匙,以保证解密正确 $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; $string_length = strlen($string); $result = ''; $box = range(0, 255); $rndkey = array(); // 产生密匙簿 for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); } // 用固定的算法,打乱密匙簿,增加随机性,好像很复杂,实际上对并不会增加密文的强度 for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } // 核心加解密部分 for($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; // 从密匙簿得出密匙进行异或,再转成字符 $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); } if($operation == 'DECODE') { // 验证数据有效性,请看未加密明文的格式 if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { // 把动态密匙保存在密文里,这也是为什么同样的明文,生产不同密文后能解密的原因 // 因为加密后的密文可能是一些特殊字符,复制过程可能会丢失,所以用base64编码 return $keyc.str_replace('=', '', base64_encode($result)); } }
2022年06月17日
121 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP判断是否是URL
<?php function isUrl($s){ return preg_match('/^http[s]?:\/\/'. '(([0-9]{1,3}\.){3}[0-9]{1,3}'. // IP形式的URL- 199.194.52.184 '|'. // 允许IP和DOMAIN(域名) '([0-9a-z_!~*\'()-]+\.)*'. // 三级域验证- www. '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.'. // 二级域验证 '[a-z]{2,6})'. // 顶级域验证.com or .museum '(:[0-9]{1,4})?'. // 端口- :80 '((\/\?)|'. // 如果含有文件对文件部分进行校验 '(\/[0-9a-zA-Z_!~\*\'\(\)\.;\?:@&=\+\$,%#-\/]*)?)$/', $s) == 1; } $url = "https://www.baidu.com"; if(isUrl($url)){ echo 11; }else{ echo 00; } ?>
2022年06月17日
95 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP查看两个数组值的区别
/** * @param $arr1 提交的参数 * @param $arr2 查到的参数 * @return array 返回值 * @description 查看数组值的区别 */ function diffArray($arr1 , $arr2 ){ $arrRet = array(); #针对关联数组 if(is_assoc($arr1) && is_assoc($arr2) ){ if (empty($arr1)) { $arr1 = array(); } if (empty($arr2)) { $arr2 = array(); } foreach ($arr1 as $key => $value){ if(!in_array($key, array_keys($arr2))){ if(!array_key_exists($key, $arrRet)){ array_push($arrRet, $key); } continue; } if($arr1[$key] !== $arr2[$key]){ if(!array_key_exists($key, $arrRet)){ array_push($arrRet, $key); } } #针对元素为数组的情况 if(is_array($value)){ array_merge($arrRet,diffArray($value,$arr2[$key])); } } }elseif(is_assoc($arr1)===false && is_assoc($arr2)===false) {#针对索引数组 $arrRet = array_merge(array_diff($arr1, $arr2),array_diff($arr2, $arr1)); }else { new Exception("数组类型不一致!"); } return $arrRet; } /** * @param $arr * @return bool|int * 判断是否是索引数组 */ function is_assoc($arr) { if(!is_array($arr)) return -1; return !(array_values($arr) === $arr); }
2022年06月17日
70 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP多维数组转一维数组
function multi2array($array) { static $result_array = array(); foreach ($array as $key => $value) { if (is_array($value)) { multi2array($value); } else{ $result_array[] = $value; } } return $result_array; } function _arr($array,$return=[]){ array_walk_recursive($array,function($value)use(&$return){$return[]=$value;}); return $return; }
2022年06月17日
145 阅读
0 评论
0 点赞
1
2
3