Speaking of Global Annoyance
| From: | Kevin Leavell | Date: | Mon, 18 Dec 2000 23:39:25 +0000 |
| Subject: | Speaking of Global Annoyance | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30958@lists.php.net to get a copy of this message | ||
I want to return the array of image names ($imagename) from a directory so
the script doesn't have to read the directory constantly. I have tried
global and return and $GLOBAL but $imagename comes back empty.
It works just fine until I try to implement the function.
function getimages()
{
chdir("images"); //read image names from directory /images
$dir = dir(".");
$dir->rewind();
while ($file=$dir->read())
{
if(!is_dir("$file")) //if the variable isn't a directory then put it in the
array imagename
{
$imagename[$file] = $file; //adds the filename to the array imagename
}
}
}
Image viewing code here
Thanks
Kevin Leavell