以下脚本将代码附加到同一文件的末尾
$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>";
}
我想将此附加到特定行,例如第 12 行
这个追加的结果如下
{
levels: [
{ file: "/bkaovAYt-3647661.mp4" },
{ file: "/bkaovAYt-3647661.mp4" }
],
title: "bkaovAYt-3647661.mp4"
},
这可能吗 ?