how to assing values into global array inside a function? (php)
<p>I have a function that searches for a string inside a text file. I want to use the same function to assign all lines to an array in case I am going to replace that string. So I will read the input file only once.</p>

<p>I have the search function working but I do not know how to deal with the array thing.</p>

<p>the code is something like that (I made the code sample much simpler,so please ignore the search function that actually isn't below)</p>

<pre><code>function read_ini($config_file_name,$string){
 $config_file = file($config_file_name);
  foreach($config_file as $line) {
  return_string = trim(substr($line,0,15));
  $some_global_array = $line'
 }
}
echo read_ini('config.ini','database.db')
if ($replaced) {file_put_contents('config.ini', $some_global_array);}
</code></pre>
