How to remove empty values from array in PHP?

How to remove empty values from array in PHP?

In this post we will give you information about How to remove empty values from array in PHP?. Hear we will give you detail about How to remove empty values from array in PHP?And how to use it also give you demo for it if it is necessary.

you have array with empty value and you want to remove all empty value from that array without loop. you can remove your all empty value from array without loop. PHP array_filter function through you can remove all empty value, you can do both way try and see following example how to do this :

Example:

$example = array(100, "hari", "","hey", "", 77, "hello");

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

return !empty($value);

});

print_r($result);


$resultDirect = array_filter($example);

print_r($resultDirect);

Output:

Array

(

[0] => 100

[1] => hari

[3] => hey

[5] => 77

[6] => hello

)

Hope this code and post will helped you for implement How to remove empty values from array in PHP?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

6  +    =  16

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US