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 \"
$arr = array("This", " ", "is", " ", "a", " ", "test."); $result = array(); for($arr as $x) { if(!preg_match("/^\s*$/", $x)) $result[] = $x; } $arr = $result;