This is the fastest way I've seen to remove empty array elements without having to do your own loop.
<?php
$data = array(
'name' => "Ted',
'age' => 20,
'extra' => ''
);
array_filter('strlen', $data);
Remember, array format changes the reference of the array passed on, so you do not need to re-assign $data.
* Fixed thanks MikeXS










