Home  >  Article  >  Backend Development  >  php array_filter filters null values ​​​​in the array

php array_filter filters null values ​​​​in the array

不言
不言Original
2018-04-20 14:42:263422browse

The content of this article is about php array_filter filtering empty values ​​​​in the array. It has a certain reference value. Now I share it with you. Friends in need can refer to it

<?php
$arr = [&#39;&#39;,2,1,3,4,5];
$arr = array_filter($arr);
print_r($arr);


Output: Array ( [1] => 2 [2] => 1 [3] => 3 [4] => 4 [5] => 5 )

Usually used together with array_unique

##array_filter(array_unique($arr)); to remove empty values ​​and heavy values

The above is the detailed content of php array_filter filters null values ​​​​in the array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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