Q: Accessing elements from a PHP array I am trying to access a property called 'ChatId' that is returned in the curl_exec command to the variable server_output.
$server_output = curl_exec($ch);
$output = json_decode($server_output, true);

After this I tried running:
var_dump(get_object_vars($output));

But $output is actually an array and not an object. So when I run var_dump($output) I get the output:
array(1) {
  ["Chats"]=>
  array(1) {
    [0]=>
    array(1) {
      ["Chat"]=>
      array(3) {
        ["ChatId"]=>
        int(11845)
        ["UserId"]=>
        string(16) "d9729feb63a1a015"
        ["SystemId"]=>
        string(33) "d9729feb63a1a015~434534343"
      }
    }
  }
}

The only property I want to access is the ChatId property but I am having difficulty doing so.

A: For future reference, each array(x) is opening up a new level of elements, where x is how many elements this level has. So if we are to remove these and think of a structure similar to the directory structure we get this:
$output
--->["Chats"]
    ---> [0]
         ---> ["Chat"]
             ---> ["ChatId"]
             ---> ["UserId"]
             ---> ["SystemId"]

So if ChatId was the file you would want to get to you would first have to go to the "Chats" directory, then the [0] one, then the ["Chat"] one and then you can select the file you want.
So
 $output["Chats"][0]["Chat"]["UserId"]

Hope this will help you in the future while working with arrays.
