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

How to remove null values ​​from php array

L
LOriginal
2020-06-01 15:20:533264browse

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);
?>

Result:

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

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!

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