I have the mysql results ($date_options) as below
Array (
[0] => stdClass Object (
[id] => 4
[start_date] => 2010-09-29
)
[1] => stdClass Object (
[id] => 13
[start_date] => 2010-10-06
)
)
I need to be able to search in the “id” field if some value existed. I tried this and it didn’t work:
array_search($event_id, $date_options, true)
$event_id is has the id value. I only want to look in id and not in start_date
How to solve this?
Thanks
Since you’re already using MySQL, why don’t you select only the ID you are interested in? That would be more efficient than retrieving all records and then searching in PHP.
If you still want to do it this way, you can simply iterate over the array and check manually: