title: Modify array values in a file
body: <p>I have a php file with some arrays in it. I want to modify one of these arrays and write it back to the file. For e.g. say file test.php has contents -</p>
  
  <pre><code>&lt;?php
  $arr1 = array("a"=&gt;"b", "c" =&gt;"d");
  $arr2 = array("a2" =&gt; "b2", "c2" =&gt; "d2");
  </code></pre>
  
  <p>i want to change $arr1 so that test.php now looks like -</p>
  
  <pre><code>&lt;?php
  $arr1 = array("a"=&gt;"b", "c" =&gt;"d", "e"=&gt;"f");
  $arr2 = array("a2" =&gt; "b2", "c2" =&gt; "d2");
  </code></pre>
  
  <p>I do not know what arrays are present in the file beforehand.</p>
  
  <p>Edit: i am not adding any variables to the array, only another key value pair. The problem is that the array is part of a file with more arrays in it about which I won't always be aware. I can achieve this if there was only one array in the file, but want to know if it is possible to do this with multiple arrays.</p>