How can the code snippet be optimized to handle multiple language options more efficiently?

The code snippet can be optimized by using an array to store the language options and their corresponding translations. This way, the code can easily handle multiple language options without the need for multiple if-else statements. By using an associative array, we can map the language options to their translations efficiently.

// Define an associative array to store language options and their translations
$languages = array(
    'english' => 'Hello',
    'spanish' => 'Hola',
    'french' => 'Bonjour'
);

// Check if the selected language exists in the array, if not, default to English
$selected_language = isset($_GET['lang']) ? $_GET['lang'] : 'english';

// Output the corresponding translation based on the selected language
echo $languages[$selected_language];