How to remove empty values from array in PHP?

Today now in this blog i will show you how to remove empty values from array in php. When we have an array also with the empty value and we want to remove all empty value from that array also without using any loop. we can remove our all empty value from an array without using loop. For PHP array_filter function through we can remove all empty value, we can also do both way try and see following example how to do this :


$example = array(100, "hari", "","hey", "", 77, "hello");
$result = array_filter($example, function($value) {
			  return !empty($value);
$resultDirect = array_filter($example);


    [0] => 100
    [1] => hari
    [3] => hey
    [5] => 77
    [6] => hello

Read Also : Laravel and AngularJS CRUD with Search & Pagination Example

Thanks for read. I hope it help you. For more you can follow us on facebook.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →