We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,676 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

php auto generate code on the same file

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>
2
Contributors
2
Replies
8 Hours
Discussion Span
9 Months Ago
Last Updated
3
Views
ska_defender
Newbie Poster
21 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

Huh?

diafol
Keep Smiling
Moderator
10,630 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

I want to append this to a specific line
for example at line 12

ska_defender
Newbie Poster
21 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0812 seconds using 2.67MB