/** * 数字转日期递归 *@param list *@return list **/ function day2str($key,$obj,$keys=array('create_time'=>'Y-m-d','s_time'=>'Y-m-d','e_time'=>'Y-m-d','usetime'=>'Y-m-d G:i:s')){ if(is_array($obj)){//如果是 obj 或 数组 foreach ($obj as $k => $v) { $obj[$k] = day2str($k,$v,$keys);//递归 } return $obj; }else{ if(!$type= $keys[$key] ){//去掉列表没有的项目 return $obj; } if(is_numeric($key) ){//去掉数组类型 return $obj; } if(!$obj){//去掉空值 return ""; } if(!is_numeric($obj) ){//去掉已转型过的 return $obj; } return date($type,$obj);//数字转字串 }
day2str('',$data);
The above introduces the PHP recursive formatting number type, including PHP and formatting content. I hope it will be helpful to friends who are interested in PHP tutorials.