PHP - compact_array()

// usage: $compacted_array = compact_array($array); 
// this function removes blank entries from an array and returns
// a new array with only populated entries.

function compact_array($array)
{
  foreach ($array as $entry)
    if (trim($entry) != '') $compacted[] = $entry;
  return $compacted;
}