function filterList($objectList, $attributeToCompare, $value) {
$filteredList = array();
foreach ($objectList as $object){
if (is_array($attributeToCompare)) {
for ($i = 0; $i <
sizeof($attributeToCompare); $i++) {
if
(strpos($object->{$attributeToCompare[$i]}, $value) !== false){
$filteredList[] =
$object;
break;
}
}
} else {
if
(strpos($object->{$attributeToCompare}, $value) !== false){
$filteredList[] = $object;
}
}
}
return $filteredList;
}
----------------------
Now as $attributeToCompare it accepts array and I also added a check
!== false, because strpos can return 0, if the search is just on the
beginning - and the whole if fails even if it shouldn't
Thanks Vitek