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 -
<?php
$arr1 = array("a"=>"b", "c" =>"d");
$arr2 = array("a2" => "b2", "c2" => "d2");
i want to change $arr1 so that test.php now looks like -
<?php
$arr1 = array("a"=>"b", "c" =>"d", "e"=>"f");
$arr2 = array("a2" => "b2", "c2" => "d2");
I do not know what arrays are present in the file beforehand.
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.