title: access object array in php from json decode
body: <p>I have this response from <code>json_decode()</code></p>
  <pre><code>// Decode JSON into PHP array
  $response_data = json_decode($curl_data, true);
  
  $user_data = $response_data;
  var_dump($user_data);
  </code></pre>
  <p>Response :</p>
  <pre><code>array(3) { [&quot;Items&quot;]=&gt; array(1) { [0]=&gt; array(3) { [&quot;date&quot;]=&gt; string(9) &quot;4/12/2022&quot; [&quot;ongoing&quot;]=&gt; string(1) &quot;1&quot; [&quot;id&quot;]=&gt; string(1) &quot;1&quot; } } [&quot;Count&quot;]=&gt; int(1) [&quot;ScannedCount&quot;]=&gt; int(1) }
  </code></pre>
  <p>now I just wanted to get the ongoing part so I did it like this</p>
  <pre><code>if(!empty($user_data))
  {
    foreach($user_data as $user)
    {
      var_dump($user[0]-&gt;ongoing);
    }
  }
  </code></pre>
  <p>but it gives me an error</p>
  <p><a href="https://i.stack.imgur.com/HzAWV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HzAWV.png" alt="enter image description here" /></a></p>
  <p><code>$user_data</code> has the response above. Why is it giving me an error like that</p>
  <p>now I have a different error when I tried this</p>
  <pre><code>// Decode JSON into PHP array
  $response_data = json_decode($curl_data, true);
  
  // Print all data if needed
  // print_r($response_data);
  // die();
  
  // All user data exists in 'data' object
  $user_data = $response_data;
  
  if(!empty($user_data))
  {
    foreach($user_data as $user)
    {
      var_dump($user[0]['ongoing']);
    }
  }
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ykDfK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ykDfK.png" alt="enter image description here" /></a></p>