手机
当前位置:查字典教程网 >编程开发 >php教程 >php下几个常用的去空、分组、调试数组函数
php下几个常用的去空、分组、调试数组函数
摘要:dump()把数组以数组格式数组,有益于调试functiondump($vars,$label='',$return=false){if(i...

dump() 把数组以数组格式数组,有益于调试

function dump($vars, $label = '', $return = false){

if (ini_get('html_errors')) {

$content = "<pre>n";

if ($label != '') {

$content .= "<strong>{$label} :</strong>n";

}

$content .= htmlspecialchars(print_r($vars, true));

$content .= "n</pre>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下几个常用的去空、分组、调试数组函数】相关文章:

一个用于mysql的数据库抽象层函数库

PHP中4种常用的抓取网络数据方法

php生成随机密码的自定义函数

在php中使用sockets:从新闻组中获取文章

一个高ai的分页函数和一个url函数

自定义PHP分页函数

php自定义hash函数实例

php中关于socket的系列函数总结

PHP中的一些常用函数收集

php动态函数调用方法

精品推荐
分类导航