Associative array in php

$num_array = [1000 => "one thousand", 100 => "one hundred", 600 => "six hundred"];
$num_array[\*] = "New Element in \$num_array";
echo $num_array[1001]; // Prints: New Element in $num_array

$animals_array = ["panda"=>"very cute", "lizard"=>"cute", "cockroach"=>"not very cute"];
array_push($animals_array, "New Element in \$animals_array");
echo $animals_array[0]; // Prints: New Element in $animals_array

why is echo $num_array[1001] giving o/p as New Element in $num_array because we have never mentioned 1001 as its key?

this question is from one topic of PHP course.

From the lesson text:

If no integer keys have been used, it will associate it with the key 0 , otherwise it will associate it one more than the largest integer used thus far.

So if we have an array:

$num_array = [1000 => "one thousand", 100 => "one hundred", 600 => "six hundred"];
//The largest integer used as a key thus far is 1000, so the next one used
//automatically when we don't specify a key will be 1001
$num_array[] = "New Element in \$num_array"; //This element is added with key 1001
//We can check this with a print_r
print_r($num_array);

Output:

(
[1000] => one thousand
[100] => one hundred
[600] => six hundred
[1001] => New Element in $num_array
)

Hope this helps!