I have an array witch contains badge objects. I'm trying to remove objects that don't match search criteria, at the moment the criteria is if the name doesn't match a searched string
The code i have so far is
foreach ( $badgeList as $key=>$badge ) {
$check = strpos($badge->getName() , $_POST['name']);
if($check === false) {
unset($badgeList[$key]);
print "<br/>" . $badge->getName() . " -- post: " . $_POST['name'];
}
}
Whats happening is its remove all objects from the array, even those that do match the string
This is whats being printed
Outdoor Challenge -- post: outdoor
Outdoor Plus Challenge -- post: outdoor
Outdoor Challenge -- post: outdoor
Outdoor Challenge -- post: outdoor
Nights Away 1 -- post: outdoor
Year 1 -- post: outdoor
Nights Away 5 -- post: outdoor