function saveIt() { // pr($_POST); $lm = new LangModel(); $arr = $lm->getOrderBy('lang_id ASC'); //pr($arr); global $activeLang; //pr($activeLang); $satulang = array(); // foreach($activeLang as $ll){ // $_lang = array(); // include("lang/" . strtolower($ll) . ".php"); // $satulang[$ll] = $_lang; // } foreach ($arr as $val) { foreach ($activeLang as $ll) { $name = base64_encode($ll . "_" . $val->lang_id); $satulang[$ll][$val->lang_id] = $_POST[$name]; } } foreach ($activeLang as $ll) { $txt = "<?php" . PHP_EOL; $myfile = fopen("lang/" . strtolower($ll) . ".php", "w+") or die("Unable to open file!"); foreach ($satulang[$ll] as $id => $value) { if ($value != "") { $txt .= '$_lang["' . $id . '"] = "' . $value . '";' . PHP_EOL; } } //$txt = "John Doe\n"; //fwrite($myfile, $txt); //$txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile); } echo Lang::t('Success'); }