Skip to content

How to remove all the empty elements of an array with php ?

Last updated on January 17, 2018

This post is about removing empty elements from the given array using PHP. Here is example

$test_array = array('foo', 'bar', '', 'sleep', '',null,'arjun');
$test_array = array_filter($test_array);
print_r($test_array);

Functions :

array_filter — Filters elements of an array using a callback function

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments