Several common php examples of getting empty, grouping, and debugging array functions _ PHP Tutorial

Source: Internet
Author: User
Several common php functions, such as empty removal, grouping, and debugging of array functions. Dump () uses arrays in array format. it is helpful for debugging functiondump ($ vars, $ label, $ returnfalse) {if (ini_get (html_errors) {$ contentpren; if ($ label !) {$ Co 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

Http://www.bkjia.com/PHPjc/319779.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319779.htmlTechArticledump () puts arrays in array format, which is useful for debugging function dump ($ vars, $ label = '', $ return = false) {if (ini_get ('HTML _ errors ') {$ content = "pre \ n"; if ($ label! = '') {$ Co...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.