function filename($prefix) { $array_to_return = array(); $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ $array_to_return[] = $filename; } return $array_to_return; } If this better explains it. The first return will stop the process you need to put the information into an array and then return the array outside of the foreach loop. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php