function format_date($time){     $t=time()-$time;     $f=array(         '31536000'=>'年',         '2592000'=>'个月',         '604800'=>'星期',         '86400'=>'天',         '3600'=>'小时',         '60'=>'分钟',         '1'=>'秒'     );     foreach ($f as $k=>$v)    {         if (0 !=$c=floor($t/(int)$k)) {             return $c.$v.'前';         }     } } echo format_da

$timestamp = time(); $startTime = strtotime(date('Y-m-d',strtotime('+0 week Monday',$timestamp))); $endTime = strtotime(date('Y-m-d',strtotime('+0 week Sunday',$timestamp)))+24*3600-1; print_r($startTime); echo "/"; print_r($endTime); //如果要获取两周时间 把+0 改成 -1 就可以了 如下图,代表上一周和本周开始时间和结束时间

$arr=array(); $arr=getdate(); $num=$arr['wday']; $start=time()-($num-1)*24*60*60; $end=time()+(7-$num)*24*60*60; $data['cid']=118; $data['createtime'] = array('between',array($start,$end)); print_r($data); exit(); //更多查询时间段查询 <?php /* *按今天,本周,本月,本季度,本年,全部查询预约单数据 * $day 代表查询条件 $cid 代表 公司id *返回array $data 查询条件 数组 */ class

查找一个元素是否在数组中,一共有上面三种做法:in_array '函数在数组中搜索给定的值。in_array(value,array,type)type 可选。如果设置该参数为 true,则检查搜索的数据与数组的值的类型是否相同。 array_key_exists 'array_key_exists() 函数判断某个数组中是否存在指定的 key,如果该 key 存在,则返回 true,否则返回 false。array_key_exists(key,array)array_search 'array_search() 函数与 in_array() 一样,在数

演示代码: public function mds($val='加密值'){ $fp_private = fopen('key/rsa_private_key.pem','r');//私钥 $private_key = fread($fp_private,8192); fclose($fp_private); $fp_public = fopen('key/rsa_public_key.pem','r');//公钥 $public_key = fread($fp_public,8192); fclose($fp_public); $pi_key = openssl_pkey_get_private($private_key);//私钥验证 $pu_key = openssl_pkey_get_public($public_key);//公钥验证

//前端出入:WkjxO9EYhuKNm6inR8HghuYJeffVZJVCWchM6dovk\/y5YHohyrExniMihFRGm+aLufqZ. //输出的话加号不能输出,使用URLencode和rawurldecode函数就可以解决了; $string = URLencode($token); $string = rawurldecode($string); print_r($string);

/**      * [getTree 遍历菜单]      * @author xiaoliu      * @DateTime 2019-11-24T10:59:20+0800      * @return   [json]                           [description]      */     public function getTree($data, $pId)     {         $tree = [];         foreach($data as $k => $v)         {             if($v['pid'] == $pId)             {         //父亲找到儿子

$first ="hello"; $hello ="world"; echo $first." ".$$first; 结果:hello world $$first就是$hello,因为$first的值是hello 这里的两个$$定义变量代表为可变变量。 另外一种: $a='hello'; $$a = 'world'; echo "$a ${$a}"; 结果:hello world 这种事直接在双引号中输出变量才需要添加{}符号输出,不带的话则是输出变量名