Code sharing for cleverly using the array_filter() function in PHP to remove multi-dimensional null values_PHP Tutorial

WBOY
Release: 2016-07-21 15:16:52
Original
924 people have browsed it

In fact, we can use the array_filter function to easily remove multi-dimensional null values ​​without changing the subscript of the array. The following is an example of usage:
$array = array(
0 => 'Brother Tao ',
1 => false,
2 => 1,
3 => null,
4 => '',
5 => 'http:/ /www.jb51.net',
6 => '0'
);
print_r(array_filter($array));
?>
The output of the above code is:
Array
(
[0] => Brother Tao
[2] => 1
[5] => http://www.jb51.net
)
In this way, values ​​that are empty, null, or false are excluded to avoid loopholes in the program!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325822.htmlTechArticleIn fact, we can use the array_filter function to easily remove multi-dimensional null values ​​without changing the subscript of the array. Here is an example usage :?php $array = array( 0 = 'Brother Tao', 1 = false, 2 = 1, 3...
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!