What is the best practice for organizing and accessing translations in PHP arrays?

When organizing translations in PHP arrays, it is best practice to use a multidimensional array structure where each language is represented by a key, and the translations are stored as values. This allows for easy access to translations based on the selected language. To access a translation, simply specify the language key followed by the specific translation key.

// Example of organizing translations in a multidimensional array
$translations = [
    'en' => [
        'hello' => 'Hello',
        'goodbye' => 'Goodbye'
    ],
    'fr' => [
        'hello' => 'Bonjour',
        'goodbye' => 'Au revoir'
    ]
];

// Accessing translations
$selectedLanguage = 'en';
echo $translations[$selectedLanguage]['hello']; // Output: Hello
echo $translations[$selectedLanguage]['goodbye']; // Output: Goodbye