Hello,
The following script writes to a file include.php
<?php
$path = "./files/";
$path2="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/";
//echo $path2;
$folder = opendir($path);
$start="";
$Fnm = "./include.php";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."\n");
while( $file = readdir($folder) ) {
if (($file != '.')&&($file != '..')&&($file != 'index.htm')) {
$result="{\nlevels: [\n{ file: \"$path2$file\" }\n],\n\ntitle: \"$file\"\n},\n";
fwrite($inF,$result);
}
}
fwrite($inF,"");
closedir($folder);
fclose($inF);
?>
It searches the folder and look for any file and store it in $path2$file
so the result posted in include.php is (If the folder has one file)
{
levels: [
{ file: "path to/files/filename" }
],
title: "filename"
},
and if the folder has 2 files result is
{
levels: [
{ file: "path to/files/filename1" }
],
title: "filename2"
},
{
levels: [
{ file: "path to/files/filename2" }
],
title: "filename2"
},
and so on...
What I need is to search for another folder /images and write the same image file in include.php just below: { file: "path to/files/filename1" }
So the result will be
{
levels: [
{ file: "path to/files/filename1" }
],
image: "path to/images/imagefilename1",
title: "filename2"
},
and it will post the same image path for every image file in images folder
I have tried to incorporate the same code with slight variable changes but I am stuck at using while
Any help ?