public function filter($index, $value) {
if($this->tasks) {
foreach ($this->tasks as $id => $t) {
if($t->$index != $value) {
unset($this->tasks[$id]);
}
}
} else {
echo "Tasks are empty";
}
}
So I am having a problem with the function above searching multidimensional objects. What I mean by that is like these:
$task->form->id
$task->form->type
$task->author->id
$task->fields->[FIELDNAME]->value
$task->form->template->id
$task->id
etc. These are the kinds of fields that need to be accessed. I thought that I could just, in $index, put "form->id" but that didn't work. For my application, I literally can spell it out. I just don't want to have to write a function for each to the last, because some of them (as you can see) only need to be on the first level and some need to be all the way down four objects.
Just tell me what more data you need and I will give it. I know every keystroke intimately so it sometimes means I forget to share something.
If you help, thank you so much.
WHAT I DID
Okay so I got it to work but I did something different.
Within the Form
class
public function search($value, $type = NULL) {
if(is_object($this->fields)) {
foreach($this->fields as $page) {
foreach($page as $name=>$field) {
if($name != "pdata") {
if ($type != NULL && $field->type == $type && $field->value == $value || $type == NULL && isset($field->value) && $field->value == $value) {
return true;
}
}
}
return false;
}
} else {
//Probably corrupted
return false;
}
return false;
}
Outside of it I can just call this function and delete or add based on whether it returns true or false.