/PHP-Language-Array

Just a simple array structure utilizing functions and echo to return results

Primary LanguagePHP

You can call any string from the array like so in a simple echo

`<?php echo $lang['common']['close'][LANG]; ?>` which returns "Cerca"

The function for this is `$lang[StringSetToUse][WordToTranslate][LANGorTheLanguageYouPrefer];`

I included a function to call the language. not much different or easier, but lets put the FUN back in function

Just use this code here `<?php echo stringLang('common','home'); ?>` and it will return "Casa"

The function for this is stringLang(StringSetToUse,WordToTranslate,LanguageIfNotDefault);

Define your language globally, so put this somewhere global

`define(LANG,"esp"); `

Below is the array structure and the function setup

``` global $lang; $lang = array ( "common" => array( "menu" => array("eng"=>"Menu","esp"=>"Menú"), "close" => array("eng"=>"Close","esp"=>"Cerca"), "home" => array("eng"=>"Home","esp"=>"Casa") ), "search" => array( "submit" => array("eng"=>"Submit","esp"=>"Enviar"), "notfound" => array("eng"=>"Item not found","esp"=>"Objeto no encontrado") ) );

/* keep this with the language array, or add to your own functions file */
function stringLang($cat,$word,$language = LANG) {
	global $lang;
	$str = $lang[$cat][$word][$language];
	return $str;		
}