Okay hello,
Total newbie of course (don't kill me!)
I have 2 scripts currently and I want to 'sort of' merge them... still with me???
Okay pretty simple... what I want them to do is pick a file from the current directory (an image file) and choose one of these randomly then display (echho/print etc) the filename. beyond this I can probably manipulate it further myself.
The two scripts i had in mind were this 1 that lists the files in the current directory (but not the ".", the ".." or the "index.php" files):
<START>
$handle=opendir('.');
while ($file = readdir($handle))
{
if ($file != "." && $file != ".." && $file != "index.php")
{
echo "$file\r";
}
}
closedir($handle);
<END>
And the other script that will output a random line from a specified textfile:
<START>
function randomline($filename)
{
$file = file($filename);
srand((double)microtime()*1000000);
while ($randomquote == "")
{
$randomquote = ereg_replace("\n","",$file[rand(0,count($file))]);
}
echo $randomquote;
}
<END>
Still with me???
I sort of understand how each script works individually but I also understand the difficulties in directly using both of them.
Should i use arrays?? if so how??
Any help would be gratefully accepted as I want to get started with this PHP stuff asap🙂
Thanks in advance to all you clever ppl.
Rob