note 22297 added to function.array-filter

From: Date: Thu, 13 Jun 2002 08:14:36 +0000
Subject: note 22297 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-31788@lists.php.net to get a copy of this message
I was looking for a function able to take some values out of an array iteratively, and found array_filter very useful although i had some trouble figuring out the proper syntax... class someclass { var $current; /** this is our iterative function */ function main ($variable,$array){ if (end test){ return true; } $variable= some treatment... if (in_array($variable, $array)){ $this->current=something...($variable); // this is the not-well-documented part $array=$array_filter($array, array($this, "array_reduce"); } $this->main($variable, $array); } /** this is the function used to filter */ function reduce_list($var){ return ($var!=$this->current); } } -- http://www.php.net/manual/en/function.array-filter.php http://master.php.net/manage/user-notes.php?action=edit+22297 http://master.php.net/manage/user-notes.php?action=delete+22297 http://master.php.net/manage/user-notes.php?action=reject+22297

« previous php.notes (#31788) next »