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

不言
Release: 2023-03-24 14:40:02
Original
3421 people have browsed it

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);
Copy after login


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!

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