Code: Select all
$greeting=array('en'=>'Hello', 'de'=>'Guten Tag', 'fr'=>'Bonjour');
echo $greeting[$lang];I would like to create the array and index it in one statement. Something like this:
Code: Select all
echo array('en'=>'Hello', 'de'=>'Guten Tag', 'fr'=>'Bonjour')[$lang];Why is it illegal, and is there another way to achieve what I want without using a $greeting variable?
--
Claus