In associative array, elements are defined in key/value pairs. When using an associative array and wanting to access all data in it, the keys are also of relevance. For this, the foreach() loop must also provide a variable name for the element's key, not only for its value.
Solution
In associative array, elements are defined in key/value pairs. When using an associative array and wanting to access all data in it, the keys are also of relevance. For this, the foreach() loop must also provide a variable name for the element's key, not only for its value.
Output of the above code -
need an explanation for this answer? contact us directly to get an explanation for this answerOne : Cat Two : Dog Three : Elephant Four : Fox