php auto generate code on the same file
<p>The following code generates a new php file playlist.php which contains the code as in $start $result variable</p>

<pre><code>$path = "./files/";
$path2="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/";
//echo $path2;
$folder = opendir($path);
$start="&lt;asx version='3.0'&gt;\n&lt;title&gt;Example ASX playlist&lt;/title&gt;";
$Fnm = "./playlist.php";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."\n");
while( $file = readdir($folder) ) {
 if (($file != '.')&amp;&amp;($file != '..')&amp;&amp;($file != 'index.htm')){
 $result="&lt;entry&gt;\n&lt;title&gt;$file&lt;/title&gt;\n&lt;ref href='$path2$file'/&gt;\n&lt;param name='image'     value='preview.jpg'/&gt;\n&lt;/entry&gt;\n";
     fwrite($inF,$result);
 }
}
fwrite($inF,"&lt;/asx&gt;");
closedir($folder);
fclose($inF);
</code></pre>

<p>I want to generate the same code in the same file which contains this code on a specified line number
is this possible ?</p>

<p>The above php script generates the following code on a new file
<a href="http://tinypaste.com/ff242cd6" rel="nofollow">http://tinypaste.com/ff242cd6</a></p>
