PHP function array_filter how to filter elements in an array with a callback function
Editor to share with you the PHP function array_filter how to use the callback function to filter the elements in the array, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Array_filter uses callback functions to filter elements in the array.
Function test_odd ($var) {return ($var & 1);} $a1=array ("a", "b", 2jin3jade 4); print_r (array_filter ($A1, "test_odd"))
Output:
Array
(
[2] = > 2
[3] = > 3
[4] = > 4
)
This is all the content of the article "how the PHP function array_filter uses callback functions to filter elements in the array". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!