How I can remove all elements of an array that contain just whitespace, not whitespace in an element like \"foobar \" but just empty array elements like <
\"foobar \"
$array = array('foo',' ','bar '); foreach ($array as $key => $value) { if (trim($value) == '') unset($array[$key]); }
Array when dumped then contains:
array(2) { [0]=> string(3) "foo" [2]=> string(4) "bar " }