0

The following script append the code at the end of the same file

$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";
// build content
$fileContent=$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";
 //append to content
$fileContent .= $result;
}
}
 //append to content
$fileContent .= "</asx>";

// append to file and check status
if ( file_put_contents(__FILE__ , $fileContent , FILE_APPEND) === false )
{

echo "failed to put contents in ".__FILE__."<br>";

}

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

The result of this append is as follows

{
levels: [
{ file: "/bkaovAYt-3647661.mp4" },
{ file: "/bkaovAYt-3647661.mp4" }
],
title: "bkaovAYt-3647661.mp4"
},

is this possible ?

1 Answer 1

1

You could place that second set of code in a file, say, include.php and then use the following code to place it wherever you want in the main PHP code:

include("include.php");
Sign up to request clarification or add additional context in comments.

2 Comments

Can I use this include between javascript ? Example between <script type="text/javascript"> </script>
Of course. It literally drops that code in where the include() is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.