title: Save array to PHP file
body: <p>I have a PHP file to store an array:</p>
  
  <pre><code>&lt;?php
    $arr = array (
      "A" =&gt; "one",
      "B" =&gt; "two",
      "C" =&gt; "three"
    );
  ?&gt;
  </code></pre>
  
  <p>I am using <code>require</code> to open the file, and each entry loads into a form. (<code>foreach</code> loop) I would like to save the <code>$_POST</code> variables back (overwriting) to the original file <strong>in the same format</strong>. I have no trouble making the form and sending back the variables. I just need a way to print the array back into the original file.</p>
  
  <p>Example result:</p>
  
  <pre><code>&lt;?php
    $arr = array (
      "A" =&gt; "new value",
      "B" =&gt; "other new value",
      "C" =&gt; "third new value"
    );
  ?&gt;
  </code></pre>
  
  <p>I have been unable to use <code>print_r</code>, as the format returned is incorrect. How can I do this successfully? Thank you.</p>