note 34373 rejected from ref.array by nicos

From: Date: Fri, 25 Jul 2003 09:29:06 +0000
Subject: note 34373 rejected from ref.array by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52623@lists.php.net to get a copy of this message
Note Submitter: qartis (A.T) qartis.com ---- To remove blank entries from an array: function array_clean($array){ for($i=0;$i<count($array);$i++) { if (trim($array[$i])==""){ array_splice ($array, $i, 1); $i--; } } return $array; } Usage: $array = array("","element","",""," ","\r\n","","element2",""," \r\n"); $array = array_clean($array); //$array[0] = "element"; //$array[1] = "element2"; NOTE: This trim()s it first, so it'll also strip lone spaces, newlines and the like.

« previous php.notes (#52623) next »