I have an array like this:
$array = (
[0] => stdClass Object
(
[ID] => 420
[name] => Mary
)
[1] => stdClass Object
(
[ID] => 10957
[name] => Blah
)
)
...
I found some solution to search using loop like this:
$item = null;
foreach($array as $struct) {
if ($v == $struct->ID) {
$item = $struct;
break;
}
}
Because of the large amount of data, I want to change it so that I can retrieve multiple values instead of one value at a time (ex: $array->420 = Mary, $array->10957 = Blah,...). Which way would be the most optimal in this case?