Need to add a string into an html tag using php
Posted: Thu Jul 28, 2005 8:15 am
Hi,
I need to be able to scan a folder for its contents and then output this to a file which flash can then grab a variable from.
I can get it to scan the folder, grab the contents and output it.
The problem lies with line 8 (i think). I need to add 'THE_DIR' variable with the filename to so that it read ./music/filename rather than just ./filename.
Can any1 help plz
Thanks
Chris J
d11wtq | edited post to use PHP tags 
I need to be able to scan a folder for its contents and then output this to a file which flash can then grab a variable from.
I can get it to scan the folder, grab the contents and output it.
The problem lies with line 8 (i think). I need to add 'THE_DIR' variable with the filename to so that it read ./music/filename rather than just ./filename.
Can any1 help plz
Thanks
Chris J
Code: Select all
<?php
//define constants as constants... (at top of file, makes it easier to read!)
define('THE_FILENAME', './music/text.txt'); //defines the output file
define('THE_DIR', './music/'); //Defines the path to the folder we wish to catalog
$dir=opendir(THE_DIR);
$files=array();
while (($file=readdir($dir)) != false)
$file="$THE_DIR . " " . $file"
array_push($files, $file);
closedir($dir);
sort($files);
$handle = fopen(THE_FILENAME, 'w');
foreach ($files as $file)
{
$out = "<A href='$file'>$file</a><BR>";
echo $out; //output to screen
fputs($handle, $out); //output to file
}
fclose($handle);
?>