Home > Backend Development > PHP Problem > How to remove null values ​​from php array

How to remove null values ​​from php array

L
Release: 2023-03-01 10:40:01
Original
3324 people have browsed it

How to remove null values ​​from php array

How to remove null values ​​from php array

Function name: array_filter()

Calling method: array_filter(array) Parameter description: array) Parameter description: array is the object of the operation, we will delete the empty elements

Instance:

<?php
    $array = array(&#39;a&#39; => "abc", &#39;b&#39; => "bcd",&#39;c&#39; =>"cde",&#39;d&#39; =>"def",&#39;e&#39;=>"");    
    $b= array_filter($array);
    print_r($b);
?>
Copy after login

Result:

Array (
[a] => abc
[b] => bcd
[c] => cde
[d] => def
)
Copy after login

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to remove null values ​​from php array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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