php - Search into multidimensional stdClass Object


I have this stdClass Object:

stdClass Object ( 
[summary] => Appuntamenti 
[items] => Array ( 
    [0] => stdClass Object (
        [summary] => Busy 
        [start] => stdClass Object ( 
            [dateTime] => 2016-02-02T17:00:00+01:00 
            [timeZone] => Europe/Rome 
        [end] => stdClass Object ( 
            [dateTime] => 2016-02-02T17:30:00+01:00 
            [timeZone] => Europe/Rome 

This stdClass Object is the result of a Google Calendar request and can be longer than this.

I'd like to check if there's an event with a specific datetime, for example if results contains "Start -> 2016-02-02T17:00:00+01:00" then return true.

I found methods to search in arrays but not in multidimensional stdClass Objects.




Try simpleforeach at start:

$items = $obj->items; // assuming $obj is your initial object
$sample_date = "2016-02-02T17:00:00+01:00";
$hasNeededDate = false;

foreach ($items as $item) {
   if ($item->start->dateTime == $sample_date) {
       $hasNeededDate = true;


People are also looking for solutions to the problem: php - Using multiple tables inner join on one key item. Can't figure out what is wrong


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.