What are some best practices for structuring multidimensional arrays in PHP to make them easier to iterate through?

When working with multidimensional arrays in PHP, it can be helpful to structure them in a way that makes them easier to iterate through. One common approach is to use associative arrays with meaningful keys for each dimension. This can make it easier to access specific elements within the array and iterate through them efficiently.

// Example of structuring a multidimensional array with meaningful keys
$students = [
    'john' => [
        'age' => 20,
        'grade' => 'A'
    ],
    'emma' => [
        'age' => 22,
        'grade' => 'B'
    ],
    'alex' => [
        'age' => 21,
        'grade' => 'C'
    ]
];

// Iterating through the multidimensional array
foreach ($students as $name => $info) {
    echo $name . ": Age - " . $info['age'] . ", Grade - " . $info['grade'] . "\n";
}