Several common PHP functions for removing null, grouping, and debugging arrays. read several common PHP functions for removing null, grouping, and debugging arrays. dump () converts arrays to arrays in array format, useful for debugging functiondump ($ vars, $ label = "> <LINKhref =" http://www.php100.com//statics/style/headfloor_95
Dump () uses arrays in array format for debugging.
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 () removes null elements from the array.
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 default function is to divide the function evenly