There is a variable $list, which has some array.
printr_r($list);
Gives something like:
Array (
[0] => stdClass Object (
[ID] => 1
[name] => Martha Dandridge
)
[1] => stdClass Object (
[ID] => 35
[name] => Abigail Smith
)
[2] => stdClass Object (
[ID] => 153
[name] => Julia Gardiner
)
[3] => stdClass Object (
[ID] => 271
[name] => Hillary Rodham
)
[4] => stdClass Object (
[ID] => 124
[name] => Nancy Davis
)
)
We should check, if any entry of this array has wanted value in [name].
Like:
if($list has "Nancy Davis" or "Hillary Rodham" in [name] of some entry?) {
return true;
} else {
return false;
}
We have both “Nancy Davis” and “Hillary Rodham” in our array, so it should give true.
If we ask like this:
if($list has "George Bush" or "Lou Henry" or "Helen Herron" in [name] of some entry?) { ... }
It should give false, because there aren’t such values in any name.
There can be any number of entries in array (I mean [0], [1] ... [any]), it should check [name] of each entry.
1 Answer