Remove empty element in an array

Sometimes we construct an array in a loop and end up with an empty element at the end (or beginning) of the array.

It will look something like elem1,elem2,elem3,

To remove empty element from an array, can simply use array_filter function

Be careful, by removing empty it includes false, null, ” etc.

Leave a Reply

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