字符串拼接

字符串拼接

private static function get_field($id,$str='|'){ if(is_array($id)){ $sql="";$i=0; foreach($id as $val){ $i++; if($i<coun...

PHP方法 2022-02-08 PM 746次 0条
二维数组变成一维数组

二维数组变成一维数组

$result = array_reduce($filename, function ($result, $value) { return array_merge($result, array_values($value)); }, array());

PHP方法 2022-02-08 PM 716次 0条
将数组中特定值提取出新数组的方法array_filter

将数组中特定值提取出新数组的方法array_filter

<?php $arr=Array( Array('id' => 1,'type' => '空调'), Array('id' => 2,'type' => '电视机'), Array('id' => 3,'type' => '空调') ); function filter($elem){ return $elem['ty...

PHP方法 2022-02-08 PM 693次 0条
时间段切割,并判断当前时间是否已经过期

时间段切割,并判断当前时间是否已经过期

<?php function posttime($isToday=true){ $startTime = floor(date( 'H ',strtotime('03:35'))); $endTime = floor(date( 'H',strtotime('22:35'))); $nowtime = strtotime(date("H:...

PHP方法 2022-02-08 PM 739次 0条
自动给数组追加相关中文描述

自动给数组追加相关中文描述

$list = [ ['id' => 1, 'status' => 1], ['id' => 2, 'status' => 2], ['id' => 3, 'status' => 5], ]; $actions = [ 1 => function () { return '未提交'; }, ...

PHP方法 2022-02-08 PM 700次 0条
获取七天内的时间和周一到周日

获取七天内的时间和周一到周日

<?php $week_list = []; $week_arr = ["日","一","二","三","四","五","六"]; $time = time(); for($i = 0 ; $i<7 ; $i++){ $w...

PHP方法 2022-02-08 PM 707次 0条
堂食餐牌号码生成,从A89开始 接着不断往下继续

堂食餐牌号码生成,从A89开始 接着不断往下继续

<?php $number = 'A89'; for ($x=0; $x<=10; $x++) { $num = ++$number; echo "<hr/>"; echo $num; } A90 A91 A92 A93 A94 A95 A96 A97 A98 A99 B00

PHP方法 2022-02-08 PM 743次 0条
两个数组的值比较并计算低于某个百分比的数据

两个数组的值比较并计算低于某个百分比的数据

$arr1 = array('hour0'=>3,'hour1'=>6,'hour2'=>7); $arr2 = array('hour0'=>34,'hour1'=>213,'hour2'=>56); $result = array(); if (count($arr1) == count($arr2)) { for($i = 0; $i <...

PHP方法 2022-02-08 PM 775次 0条
多维数组指定某个key,然后累加它的和

多维数组指定某个key,然后累加它的和

<?php $arr = [ '0'=>['id'=>1,'name'=>'jack','size'=>15], '1'=>['id'=>2,'name'=>'viket','size'=>15] ]; echo array_sum(array_map(function($val){return $val['size'];...

PHP方法 2022-02-08 PM 723次 0条
禁止搜索引擎蜘蛛解决方案

禁止搜索引擎蜘蛛解决方案

if(preg_match("/(Googlebot|Msnbot|YodaoBot|Sosospider|Baiduspider|Sogou web spider|gosospider|Huaweisymantecspider|Gigabot|OutfoxBot)/i", $_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_US...

PHP方法 2022-02-08 PM 768次 0条
过滤遍历出来的字段array_filter

过滤遍历出来的字段array_filter

<?php $data = [ [ 'id' => 1, 'name' => '你好,234', 'cate' => '生活日记'], [ 'id' => 2, 'name' => '79798', 'cate' => '摄影美图'], [ 'id' => 3, 'name' => '567567', 'cate' =&...

PHP方法 2022-02-08 PM 736次 0条