《PHP-运用回调函数实现数组的筛选》

WBOY
Release: 2016-06-13 13:10:33
Original
785 people have browsed it

《PHP---使用回调函数实现数组的筛选》

1, "222"=>2, "333"=>3, "444"=>4, "555"=>5); $nums2 = $nums1; echo "
";
echo "Odd :\n";
//回调函数,如果返回true则将$array1中的数据再赋给原数组,键保持不变
print_r(array_filter($nums1, "odd"));
echo "
Copy after login
"; echo "
";
echo "Even:\n";
print_r(array_filter($nums2, "even"));
echo "
Copy after login
"; ?>

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!