What are best practices for structuring arrays in PHP to efficiently store and retrieve data?

When structuring arrays in PHP to efficiently store and retrieve data, it's important to use meaningful keys for quick access and to avoid nested arrays when possible to keep the structure simple. Additionally, organizing data in a logical way can make it easier to work with and maintain.

// Example of structuring an array efficiently
$data = [
    'user1' => [
        'name' => 'John Doe',
        'email' => 'john@example.com',
        'age' => 30,
    ],
    'user2' => [
        'name' => 'Jane Smith',
        'email' => 'jane@example.com',
        'age' => 25,
    ],
];

// Retrieving data from the array
echo $data['user1']['name']; // Output: John Doe