Perhaps A Faster Way To Remove All Empty Elements From An Array

This quick method will remove all empty elements from an array, but it has some caveats.

Code
$MyArray = array_filter($MyArray);


$MyArray will have all elements removed who's key equals:
  • (boolean) FALSE
  • (int) 0 (zero)
  • (float) 0.0 (zero point zero)
  • an empty string: ""
  • the string "0"
  • an array with zero elements
  • an object with zero member variables (PHP 4 only)
  • the special type NULL (including unset variables)
  • SimpleXML objects created from empty tags



The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)