This is my php function to change month names from english to other languages and this function is working fine.
function _ld($sqldate, $lang){
if(!$sqldate) $sqldate=date("Y-m-d");
$phpdate = strtotime( $sqldate );
$phpdate = date( 'd M Y', $phpdate );
$eng = array("Jan", "Feb", "Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$kan = array("ಜನವರಿ", "ಫೆಬ್ರವರಿ", "ಮಾರ್ಚ್","ಏಪ್ರಿಲ್", "ಮೇ", "ಜೂನ್","ಜುಲೈ", "ಆಗಸ್ಟ್", "ಸೆಪ್ಟೆಂಬರ್","ಅಕ್ಟೋಬರ್", "ನವಂಬರ್", "ಡಿಸೆಂಬರ್");
$hin = array("जनवरी", "फ़रवरी", "मार्च","अप्रैल","मई","जून","जुलाई","आगस्त","सितम्बर","अकतूबर","नवेम्बर","दिसम्बर");
switch ($lang) {
case "kan" :
$to = $kan;
break;
case "eng" :
$to = $eng;
break;
case "hin" :
$to = $hin;
break;
default :
$to = $kan;
}
return str_replace($eng, $to, $phpdate);
}
echo _ld();
Now I want to simplify this function by adding languages to array (key=>values). Is this possible? If yes, how?
Please help me.
language variablesto asingle array with key=>valuesand use it?echo _ld("2017-01-29","kan");echoes29 ಜನವರಿ 2017. I want know how to put all languages to a single array like$languages = array("Jan"=>array("Jan","ಜನವರಿ","जनवरी"),"Feb"=>array("Feb","ಫೆಬ್ರವರಿ","फरवरी"),...);and process this according to$langparameter