+ 1
Why echo $people[1] gives an error ?
It shows error on output Its an associative array <?php> $people= array("david"=>"21","amy"=>"29"); Echo $people[1]; ?> Op: error
2 Réponses
+ 7
The values have their own defined keys, so they don't "answer" to numeric keys.
Johann Ditrich has linked to the lesson:
https://www.sololearn.com/learn/PHP/1808/
+ 5
Try
echo $people['amy'];
because it's an associav and not a numeric array.
So the keys in your example are 'david' and 'amy'.
https://www.sololearn.com/learn/PHP/1808/