How can I understand the above code? Array_filter

Source: Internet
Author: User
How can I understand the code? Array_filter & lt ;? Php & nbsp; $ arr = array (0, 0, 1, 2, 4); & nbsp; $ arr = array_filter ($ arr); & nbsp; print_r ($ arr );? & Gt; do not need array_f to ask the experts how to understand the code? Array_filter
$ Arr = array (, 2 );
$ Arr = array_filter ($ arr );
Print_r ($ arr );
?>
Is array_filter (array, function) not required )? Does writing an array directly mean that the user-defined function value is zero? Or how to understand it? Please advise

------ Solution --------------------
Array array_filter (array [, callback])

Array_filter () transmits each value in the array to the callback function in sequence. If the callback function returns TRUE, the current value of the array is included in the returned result array. The key name of the array remains unchanged.

If the callback function is not provided, array_filter () deletes all entries in the array that are equal to FALSE.
If the value is false, it is null, false, 0 .......
------ Solution --------------------
Flase false true

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.