7.5 C
New York
Wednesday, March 22, 2023

How to remove null values from array in PHP?





you have array with null value and you want to remove all null value from that array without loop. you can remove your all null value from array without loop. PHP array_filter function through you can remove all null value, you see following example how to remove null value :

Example:

$example = array(100, "hardik", null, "hey", NULL, "", 77);

$result = array_filter($example, function($value) {

return !is_null($value);

});

print_r($result);

Output:

Array

(

[0] => 100

[1] => hardik

[3] => hey

[5] =>

[6] => 77

)

Try this…….

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles