Bird
0
0

Given the multidimensional array:

hard📝 Application Q8 of 15
PHP - Arrays
Given the multidimensional array:
$employees = [
['id' => 101, 'details' => ['name' => 'John', 'age' => 28]],
['id' => 102, 'details' => ['name' => 'Jane', 'age' => 32]]
];
How do you access Jane's age?
A$employees[1]['age']
B$employees[0]['details']['age']
C$employees['details'][1]['age']
D$employees[1]['details']['age']
Step-by-Step Solution
Solution:
  1. Step 1: Identify Jane's index

    Jane is the second element, so index 1.
  2. Step 2: Access nested 'details' array

    Within index 1, access 'details' key, then 'age'.
  3. Final Answer:

    $employees[1]['details']['age'] -> Option D
  4. Quick Check:

    Check array indices and keys carefully [OK]
Quick Trick: Use correct indices and keys to access nested arrays [OK]
Common Mistakes:
  • Using wrong index for Jane
  • Accessing keys in wrong order
  • Confusing associative and numeric keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes