(1)时间戳
date_default_timezone_set("Asia/Shanghai"); //时区
$time = date('Y-m-d H:i:s'); echo strtotime($time);//转时间戳
$date = date('Y-m-d H:i:s', strtotime($time));//时间格式
(2)数组转字符串&&字符串转数组
$arr = "[1,2,6,4,6,7,9,11,12,14,15,16]";
$abc = json_decode($arr, true);//json转数组$ids = implode(",", $abc);//数组转字符串$array = array('test', '测试', 'test1', 'test2');
echo "'" . implode("','", $array) . "'";(3)截取字符串
$str_bh='123456789';
$abc=substr($str_bh,-8);(4)序列化&&反序列化
$spec_arr = unserialize('');
(5)字符串去所有空格
str = "a b c d ";
$qian = array(" ", " ", "\t", "\n", "\r");$hou = array("", "", "", "", "");$array = explode(",", str_replace($qian, $hou, $str));echo '"' . implode('","', $array) . '"';(6)数组&&多维
unset($classify_arr['classify'][$k]);//移除数组中一条记录
if (in_array('手机类型', $v)) {//检查数组中存在某个值
echo 'cunzai';}