自己的php函数库

//判断数组中是否有元素为空的函数,支持多维数组,相似系统函数in_array(value,array,type)

function is_null_array($arr) 
  {
          if(!is_array($arr))
      {
            return false;
       }
          foreach($arr as $key=>$value)
               {
                     if(is_array($value)) 
                       {
                              if(!empty($value))
                                   {
                                          return is_null_array($value);
                                    } 
                        }elseif($value!='')
                               {
                                       return false;
                                     }
                      }
                              return true; 
                            }                              

$po=array('a'=>'','b'=>'','c'=>array(),'d'=>array('x'=>'3','y'=>array()));
$ret=is_null_array($po);
var_dump($ret); //结果: bool false

$po=array('a'=>'','b'=>'','c'=>array(),'d'=>array('x'=>'','y'=>array()));
$ret=is_null_array($po);
var_dump($ret); //结果: bool true

//向foreach中添加元素

foreach($carFactory as $key=>$car){
//在遍历的过程中为 car添加一个新的属性比如生产日期
$carFactory[$key]['made_time'] = time();
}
//数据库的多字段对应更新


update `sf_reply` set reAuthor=(case when reAuthor='点点' then '点点2' else reAuthor end)
,reObject=(case when reObject='点点' then '点点2' else reObject end)

及时去除json中的不可见字符

return json_decode(trim($out,chr(239).chr(187).chr(191)), true);    //去除不可见字符

//获取当前日期精确到分

$now = date('c');

PHP生成UTF-8编码的CSV文件用Excel打开中文显示乱码,是由于输出的CSV文件中没有BOM。

我们只要简单处理一下即可

print(chr(0xEF).chr(0xBB).chr(0xBF));

原文地址:https://www.cnblogs.com/yuqiandoudou/p/4734644.html