I am trying to make a site multi lingual. by building a language dictionary array ( if it is not the best way please don’t hesitate to let me know )
$fr=array();
$fr['hello']="Bonjour";
I would like to make a function that does the following :
for every word and language function ( $word ="hello",$language="fr")
it would return the right value. So far the way I am doing isn’t working
echo $$language[$word];
any ideas?
thank you
By default, variables are local to a function. If your dictionary arrays are global, you need to declare them as global, but since the names are variable, you have to access them via
$GLOBALS:As for a better way, you might want to use just one multi-dimensional array instead of creating one variable for each language: