RE: [PHP] Speaking of Global Annoyance

From: Date: Mon, 18 Dec 2000 23:41:39 +0000
Subject: RE: [PHP] Speaking of Global Annoyance
Groups: php.general 
Request: Send a blank email to php-general+get-30959@lists.php.net to get a copy of this message
1. I've taken the liberty of reformatting your code a little. > 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 > } > } > } 2. At the end of this function, $imagename is local to the function. Try this: 1. Add "return $imagename;" as the last line inside the { }'s. 2. When you call the function, make it: $imagenamearray = getImages(); ^^^^^^^^^^^^^^^ That'll be your array. Jason -- Jason Murray jasonm@melbourneit.com.au Web Design Team, Melbourne IT Fetch the comfy chair!

« previous php.general (#30959) next »