Several commonly used empty removal, grouping, and debugging array functions_PHP tutorial

WBOY
Release: 2016-07-13 17:37:34
Original
892 people have browsed it

dump() converts the array into array format, which is helpful for debugging

function dump($vars, $label = , $return = false){
If (ini_get(html_errors)) {
          $content = "
";<br>
If ($label != ) {<br>
$content .= "<strong>{$label} :</strong>
";<br>
}<br>
          $content .= htmlspecialchars(print_r($vars, true));<br>
          $content .= "
";
} else {
          $content = $label . " : " . print_r($vars, true);
}
If ($return) { return $content; }
echo $content;
Return null;
}
array_remove_empty() removes empty elements in 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 used to group functions evenly

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486547.htmlTechArticledump() Array the array in array format, which is beneficial for debugging function dump($vars, $label =, $ return = false){ if (ini_get(html_errors)) { $content = pre; if ($label != ) { $content .=...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template