PHP Remove empty string elements from array and reindex

Removes all elements from an array that are empty strings, then re-indexes the array.
$cleanedArray = array_values(array_filter($array, function($value) { return trim($value) !== ''; }));
Posted by
Snippet Viewed 4684 times.

Share your PHP code snippets:

  • Get some recognition & link back to your site.


Submit | Browse

Most Recent php snippets

Most Viewed