The following code generates a new php file playlist.php which contains the code as in $start $result variable
$path = "./files/";
$path2="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/";
//echo $path2;
$folder = opendir($path);
$start="<asx version='3.0'>\n<title>Example ASX playlist</title>";
$Fnm = "./playlist.php";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."\n");
while( $file = readdir($folder) ) {
if (($file != '.')&&($file != '..')&&($file != 'index.htm')){
$result="<entry>\n<title>$file</title>\n<ref href='$path2$file'/>\n<param name='image' value='preview.jpg'/>\n</entry>\n";
fwrite($inF,$result);
}
}
fwrite($inF,"</asx>");
closedir($folder);
fclose($inF);
I want to generate the same code in the same file which contains this code on a specified line number is this possible ?
The above php script generates the following code on a new file
<asx version='3.0'>
<title>Example ASX playlist</title>
<entry>
<title>sintel_trailer1.mp4</title>
<ref href='/files/sintel_trailer1.mp4'/>
<param name='image' value='preview.jpg'/>
</entry>
</asx>