note 22297 deleted from function.array-filter by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 09:02:43 +0000 |
| Subject: | note 22297 deleted from function.array-filter by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196849@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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...
<?php
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);
}
}
?>