Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You shouldn't read lang.php file. You should include it.</p> <p>Better way:</p> <pre><code>require_once('lang.php'); // or require_once($array_file); </code></pre> <p>and remove these lines:</p> <pre><code>// read the array into $Lang[] $file_lines = file($array_file); $Lang = array(); foreach ($file_lines as $line) { list($b4_key, $key, $b4_value, $value) = explode('"', $line); if (preg_match("/Lang/", $b4_key)) { $Lang[$key] = $value; } } </code></pre> <h1># # # # # # # #</h1> <p>As I understand your file contents only one language, doesn't it? If no, will be a little modifications in the code.</p> <pre><code>&lt;? // edit the values of an array ($Lang["key"] = "value";) in the file below $array_file = "lang.php"; // if POSTed, save file if (isset($_POST['submit'])) { unset($_POST['submit']); // remove the submit button from the name/value pairs $is_post = true; // set flag for use below // write over the original file, and write a backup copy with the date/time write_file($array_file, $new_array); write_file($array_file . date("_Y-m-d_h-ia"), $new_array); file_put_contents($array_file, serialize(array( 'timestamp' =&gt; time(), // after you can display this value in your preffered format 'data' =&gt; serialize($_POST) ))); } $Lang_content = @unserialize(@file_get_contents($array_file)); if (!array_key_exists('data', $Lang_content)) { $Lang_content = array( 'timestamp' =&gt; 0, // or time() 'data' =&gt; serialize(array()) ); } $Lang_template = array( // If you want 'TEXT' =&gt; "baer", 'GRET' =&gt; "hallo", 'FACE' =&gt; "face", 'HAPY' =&gt; "happy", 'TOOL' =&gt; "tool", ); $Lang = array_merge( $Lang_template, unserialize($Lang_content['data']) ); ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Language Editor&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;?= $array_file ?&gt;&lt;/h1&gt; &lt;? if (!isset($is_post)) { ?&gt; &lt;form action="&lt;?= $_SERVER['PHP_SELF'] ?&gt;" method="POST"&gt; &lt;? } ?&gt; &lt;table&gt; &lt;? // loop through the $Lang array and display the Lang value (if POSTed) or a form element foreach ($Lang as $key =&gt; $value) { echo "&lt;tr&gt;&lt;td&gt;$key&lt;/td&gt;&lt;td&gt;"; echo isset($is_post) ? "= \"$value\"" : "&lt;input type=\"text\" name=\"$key\" value=\"$value\"&gt;"; echo "&lt;/td&gt;&lt;/tr&gt;\n"; } ?&gt; &lt;/table&gt; &lt;? if (!isset($is_post)) { ?&gt; &lt;p&gt;&lt;input type="submit" name="submit" value="Save"&gt;&lt;/p&gt; &lt;/form&gt; &lt;? } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload