In what scenarios is it recommended to use a multidimensional array or objects instead of relying on numerical keys in PHP arrays for better data organization and manipulation?

When dealing with complex data structures that require more organization and flexibility, it is recommended to use multidimensional arrays or objects instead of relying solely on numerical keys in PHP arrays. This approach allows for better data organization, easier manipulation, and improved readability of the code.

// Using multidimensional arrays for better data organization and manipulation
$studentData = [
    'John' => [
        'age' => 20,
        'grade' => 'A'
    ],
    'Alice' => [
        'age' => 22,
        'grade' => 'B'
    ]
];

// Accessing data for a specific student
echo $studentData['John']['age']; // Output: 20
echo $studentData['Alice']['grade']; // Output: B