php string replace without finding a word
<p>I have a form field its give below.<br/></p>

<pre><code>`&lt;form method='post'&gt;
    &lt;input type='hidden' name='var'/&gt;
    &lt;input type='hidden' name='en_word' value='HOME'/&gt;
    &lt;input type='text' name='new_word'/&gt;
    &lt;input type='hidden' name='en_word' value='REWARD'/&gt;
    &lt;input type='text' name='new_word'/&gt;
    &lt;input type='hidden' name='en_word' value='LEADERBOARDS'/&gt;
    &lt;input type='text' name='new_word'/&gt;
    &lt;input type='submit'&gt;
 &lt;/form&gt;`
</code></pre>

<p>When I entered something and click the submit button it will perform a file write function(fwrite).if i entered the first input field then i click submit button i will get "home" and "whatever i entered". now i want to replace in translation.php for НАЧАЛО with new entered word("Home"=>"НАЧАЛО").I doesn't have НАЧАЛО. Now I want to replace the input word if not exist in translation.php.<br/></p>

<pre><code>    $var = $_POST['var'];
        $new_words = $_POST['new_words'];
        $en_word = $_POST['en_word'];
        for($i=0; $i&lt;count($var); $i++)
        {
        $file = '/www/translation.php';
        $handle = fopen($file, "r");
        $input = fread($handle, filesize($file));
        $stringData = html_entity_decode($new_words[$i], ENT_COMPAT, 'UTF-8');
        $first_str = "\"$en_word[$i]\""."=&gt;";
        $string="\"$stringData\"".",\n";
        fclose($handle);
        if(!eregi($first_str,$input) &amp;&amp; !eregi($string,$input))
        {
            $myFile = "/www/translation.php";
            //echo $en_word[$i];
            $fh = fopen($myFile, 'a') or die("can't open file");
            $stringData = "\"$en_word[$i]\""."=&gt;";
            fwrite($fh, $stringData);
            $stringData = html_entity_decode($new_words[$i], ENT_COMPAT, 'UTF-8');
            fwrite($fh, "\"$stringData\"".",\n");
            fclose($fh);
        }
        elseif (eregi($first_str,$input) &amp;&amp; !eregi($string,$input))
        {

// here I want to replace the input word if not exist in translation.php.
        }`
     }
</code></pre>

<p><strong>Here is the translation.php</strong><br/></p>

<p>translation.php contain a string.</p>

<pre><code>"HOME" =&gt; "НАЧАЛО",
"REWARDS" =&gt; "НАГРАДИ",
"LEADERBOARDS" =&gt; "КЛАСАЦИИ",
"LOGIN | SIGN UP" =&gt; "ВХОД / РЕГИСТРАЦИЯ",
"STORE" =&gt; "МАГАЗИН",
"LOGOUT" =&gt; "ИЗХОД",
"SET" =&gt; "ПОТВЪРДИ",
</code></pre>

<p><br/></p>

<p>Now I want to replace the input word if not exist in translation.php. how do I do this?
Is It possible to do? please help me. <br/>
Sorry! if question is not understandable please tell me I will explain clearly.</p>
