您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

数组函数 php下几个常用的去空、分组、调试数组函数

2025/6/5 20:39:40发布22次查看
dump() 把数组以数组格式数组,有益于调试
function dump($vars, $label = '', $return = false){
if (ini_get('html_errors')) {
$content =
\n;
if ($label != '') {
$content .= {$label} :\n;
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= \n
\n;
} else {
$content = $label . :\n . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
array_remove_empty()去除数组中为空的元素
function array_remove_empty(& $arr, $trim = true){
foreach ($arr as $key => $value) {
if (is_array($value)) {
array_remove_empty($arr[$key]);
} else {
$value = trim($value);
if ($value == '') {
unset($arr[$key]);
} elseif ($trim) {
$arr[$key] = $value;
}
}
}
}
array_chunk() php默认函数 作用是把函数平均分组 以上就介绍了数组函数 php下几个常用的去空、分组、调试数组函数,包括了数组函数方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product