file_put_content in loop
<p>I want to replace "uggg" word inside of the index.php with different values (I have values in array) and make new files for each replaced string and save it with the name of string.
I wrote this but it only create one file for the last value in the array.</p>

<pre><code>foreach($info_array as $rp)
{
$data = file_get_contents("index.php");
$data = str_replace("uggg", "$rp", $data);
file_put_contents($rp.".php", $data);
}
</code></pre>

<p>Here is the error when I execute this code</p>

<blockquote>
  <p>Warning: file_put_contents(john c .php) [function.file-put-contents]: failed to open     stream: Invalid argument in C:\wamp\www\n\cfile.php on line 357</p>
</blockquote>

<p>line 357 is:</p>

<pre><code>file_put_contents($rp.".php", $data);
</code></pre>

<p>what is wrong ?</p>
