![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
php
qq_30151813
这个作者很懒,什么都没留下…
展开
-
time、date 和 microtime函数区别
一、time、date 和 microtime函数 time----返回当前的 Unix 时间戳 date----格式化一个本地时间/日期 microtime----返回当前的 Unix 时间戳和微秒数二、三者的区别 1.time() 函数 time() 函数返回的是从 Unix 纪元(格林威治1970年1月1日00:00:00)到当前时间的秒数,如下 1 2 3 4 5 ...原创 2022-01-21 09:32:48 · 687 阅读 · 0 评论 -
php脚本运行时间
$start_time=microtime(true);代码$ent_time=microtime(true);$time=$ent_time-$start_time; echo "<br />当前页面执行时间为:{$time} 秒";原创 2022-01-21 09:00:50 · 460 阅读 · 0 评论 -
php二维数组排序
<?php$data = array( array( 'id' => 5698, 'first_name' => 'Bill', 'last_name' => 'Gates', ), array( 'id' => 4767, 'first_name' => 'Steve', 'last_name' => 'Aobs', ), array( 'id' => 3809, 'fi...原创 2021-10-11 16:09:29 · 104 阅读 · 0 评论 -
php根据对象属性对数组对象排序
$domain_arr=[{},{},……{}];###attribute是你要根据对象的什么属性排序usort($domain_arr, function($a, $b) {return$a->attribute< $b->attribute? 1 : -1;});原创 2021-10-11 16:08:54 · 190 阅读 · 0 评论 -
php每隔多少字,插入字符,折行换行
/** * Notes:字符串每隔多少个字符加个换行 * User: zhixinhua * DateTime: 2021/8/11 15:52 * @param $string 截取的字符串 * @param $num 间隔的字符数 * @param $insert_str 替换的字符串 * @param false $once 是否返回截取的第一段 * @return string */function str_fold_line($string, $num, $inse.原创 2021-08-18 09:04:52 · 420 阅读 · 0 评论 -
获取当天,昨天,近7天,近30天的起始时间戳
/** * @param $type * @param string $startDate * @param string $endDate * @return array * @Notes:获取当天,昨天,近7天,近30天的起始时间戳 * @Time: 2020-12-25 15:12 * @author: Xinhua.zhi */ function getDayDate($type,$startDate='',$e...原创 2021-01-05 10:02:38 · 877 阅读 · 0 评论 -
PHP文件类型判断
方法一:pathinfo代码示例:x 1 2 3 4 5 6 7 /** * 获取文件后缀(如果文件名为11.11,11不是后缀,会默认11为后缀) * $file string 文件路径或者文件名 */ function get_extension($file){ return pathinfo($file, PATHINFO_EXTENSION); } ...原创 2020-06-15 09:44:08 · 129 阅读 · 0 评论 -
php二分查找
二分查找的定义二分查找也称折半查找(Binary Search),它是一种效率较高的查找方法。但是,折半查找要求线性表必须采用顺序存储结构,而且表中元素按关键字有序排列。算法的要求从上面的定义我们可以知道,满足该算法的要求必须如下两点:必须采用顺序存储结构。 必须按关键字大小有序排列。算法的步骤其实,二分查找也还是比较容易理解的,大概就是一分为二,然后两边比较,保留有效区间,继续一分为二查找,直到找到或者超出区间则结束,所以二分查找的基本步骤是:确定要查找的区间 确定要二分时的原创 2020-05-09 11:37:42 · 100 阅读 · 0 评论 -
时间数组合并
//原来的合并值$aa=Array( [0] => Array ( [0] => 00:00 [1] => 23:59 ) [1] => Array ( [0] => 00:00 [1] =>...原创 2020-02-20 22:53:56 · 155 阅读 · 0 评论 -
php截取过长字符串
if (! function_exists('mbSubStr')){ function mbSubStr($str, $length = 0, $append = true) { $str = trim($str); $strlength = strlen($str); if ($length == 0 || $length &g...原创 2019-12-20 23:06:32 · 430 阅读 · 0 评论 -
php记录日志
@file_put_contents('/tmp/aa.log',var_export($restaurantWhere,1)."\n", FILE_APPEND);file_put_contents('/tmp/wzf.log',json_encode($SalesTime[$key])."\n",FILE_APPEND);原创 2019-05-22 20:58:13 · 641 阅读 · 0 评论 -
php计算程序运行时间
<?php$start_time = microtime(true);for ($i=0;$i<100000000;$i++){};$end_time = microtime(true);echo '循环执行时间为:'.($end_time-$start_time).' s';原创 2019-05-22 20:56:00 · 148 阅读 · 0 评论