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 = ['',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!