note 29406 added to ref.array

From: Date: Wed, 12 Feb 2003 17:13:03 +0000
Subject: note 29406 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-43832@lists.php.net to get a copy of this message
I've created a small function for the optimization of an array. It removes all empty elements and sets the next filled element to the place the empty element was. It is a function wich argument is passed by reference, so it will only return true, in case the value of the argument was correct or false if the value was incorrect. function arOpt(&$array){ // pass by reference if(!is_array($array)){ return false; } $temp; // create a temporary array; for($i = 0; $i < sizeof($array); $i++){ if(!empty($array[$i])){ $temp[sizeof($temp)] = $array[$i]; } } $array = $temp; return true; } -- http://www.php.net/manual/en/ref.array.php http://master.php.net/manage/user-notes.php?action=edit+29406 http://master.php.net/manage/user-notes.php?action=delete+29406 http://master.php.net/manage/user-notes.php?action=reject+29406

« previous php.notes (#43832) next »