jakebur01 Posted March 6, 2009 Share Posted March 6, 2009 How can I modify this function to get only a list of image urls stored in a db rather than just getting ALL the images in a directory? Example: something like: SELECT image_file_name FROM image_table WHERE `Username` = '$_SESSION[user]'; and store this list of file names into the array in the function below rather than just getting all the files in the directory. #-############################################# # desc: gets the list of image files in the directory # param: [optional] directory to look through # returns: array with alphabetically sorted list of images function GetFileList($dirname="."){ global $config; $list = array(); if ($handle = opendir($dirname)) { while (false !== ($file = readdir($handle))) { //this matches what type of files to get. jpeg, jpg, gif, png (ignoring case) if (preg_match("/\.(jpe?g|gif|png)$/i",$file)) { $list[] = $file; } } closedir($handle); } sort($list); return $list; }#-#GetFileList() Link to comment https://forums.phpfreaks.com/topic/148180-solved-modifying-function/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.