工作中用到的PHP函数
1.根据当前时间计算N天后的时间 $info = (new DateTime($nowDate))->add(new DateInterval("P{$days}D"))->format('Y-m-d’); 2.根据一个指定的时间获取改天是周几 $weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w","2015-11-26")]; 3.二维数组排序 $data = array(); $data[] = array('volume' => 67, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 1); $data[] = array('volume' => 85, 'edition' => 6); $data[] = array('volume' => 98, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 6); $data[] = array('volume' => 67, 'edition' => 7); // 取得列的列表 foreach ($data as $key => $row) { $volume[$key] = $row['volume']; $edition[$key] = $row['edition']; } array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data); 4.数组去重去空 $newData = array_unique(array_filter($oldData));
文章名称:工作中用到的PHP函数
转载源于:http://myzitong.com/article/jeoidg.html