php 生成唯一标识

function uuid( $more = true, $admin = false ) { if ( $more ) { return uniqid( md5( mt_rand() ), true ); } else { if ( $admin ) return uniqid( "zzz", false

php token生成

function token($prefix = "") { $str = md5(uniqid(mt_rand(), true)); $_id = substr($str, 0, 8) . '-'; $_id .= substr($str, 8, 4) . '-'; $_id .= substr($str, 12, 4) . '-';

php 密码盐值生成

//加密用户密码、加盐值 function getPassword($pwd, $salt) { return md5($pwd."#".PASSWORD_KEY."#".$salt); // 摘要算法md5 } function getSalt() { $salt = rand(10000000,99999999); return

php 构建curl请求

function httpCurl($url, $type = 'GET', $param = array()) { $type = strtoupper($type); $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FO

php 根据身份证号获取生日

// 根据身份证号获取生日 function getBirthdayByIDNo($idcard) { $idCardLength = strlen(trim($idcard)); // 15位身份证验证生日,转换为18位 if ($idCardLength == 15) { $sBirthday = '19'.substr($idcard,6,2)

php 根据生日计算年龄

// 根据出生日期求年龄 function getAgeByBirthday($val = "") { if($val == "") { return 45; } $tYear = date('Y'); $tMonth = date('m'); $tDay = date('d'); $year

php 获取周日期,月日期数组

function get_week($time, $format = "Y-m-d") { $week = date('w', $time); $weekname=array('星期一','星期二','星期三','星期四','星期五

php 数组填充数据

示例$list = array( array('aa'=>1,'bb'=>2), array('aa'=>3,'bb'=>4) );array_walk(array,myfunction,userdata...)array_walk() 函数对数组中的每个元素应用用户自定义函数。在函数中,数组的键名和键值是参数。您可以通过把用户自定义函数中的第一个参数指定为引用:&

php 等于和绝对等于

bool类型的值进行比较时要用绝对相等$index = array_search($li['datetime'], $searchArr); if ($index !== false) { }

mysql 查询最近7天的数据,没有数据自动补0

select a.click_date,ifnull(b.count,0) as count from ( SELECT curdate() as click_date union all SELECT date_sub(curdate(), interval 1 day) as click_date union all SELECT date_sub(cu