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 747 times.

Share your PHP code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.
Submit | Browse

Most Recent php snippets

Most Viewed

The FitDesk Under Desk Elliptical