alarik149 Posted November 21, 2006 Share Posted November 21, 2006 Good evening people:).I`m a little stuck while using some pictures.here is what I need.I have a directory "pictures/a" that contrains some pictures.I want these pictures placed in an array called $pictures,so I can use them something like $picture[1] or picture[8];.Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/ Share on other sites More sharing options...
taith Posted November 21, 2006 Share Posted November 21, 2006 i love this function... goes to the database, and adds every file into an array :-)[code]<?function get_allfiles($dir="functions/"){ if(is_dir($dir)){ if($handle = opendir($dir)){ $files = array(); while(false !== ($file = readdir($handle))){ if(($file != ".")&&($file != "..")&&($file != "index.php")){ $files[] = $file; } } closedir($handle); } }else{ return false; } asort($files); return $files;}?>[/code] Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128032 Share on other sites More sharing options...
alarik149 Posted November 21, 2006 Author Share Posted November 21, 2006 :) yes the function is really nice but I try to echo $files[1]; and I get nothing out:(. Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128045 Share on other sites More sharing options...
taith Posted November 21, 2006 Share Posted November 21, 2006 if you have it pointed to the same doccument as where your searching... your $dir needs to be "." Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128050 Share on other sites More sharing options...
kenrbnsn Posted November 21, 2006 Share Posted November 21, 2006 Take a look at the [url=http://www.php.net/glob]glob()[/url] function. I find it much easier to use.Ken Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128051 Share on other sites More sharing options...
alarik149 Posted November 21, 2006 Author Share Posted November 21, 2006 [code]function get_allfiles($dir="/pictures/a/")[/code]the files are in "pictures/a" and the script is in root.Still dosen`t work.I`ll take a peek at glob too. Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128058 Share on other sites More sharing options...
alarik149 Posted November 21, 2006 Author Share Posted November 21, 2006 ok,I managed to get the files in an array with glob.Thanks for your help taith and kenrbnsn too. Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128061 Share on other sites More sharing options...
taith Posted November 21, 2006 Share Posted November 21, 2006 one must remember that if a function returns a value, that has to be set into a fully different variable...[code]$pictures = get_allfiles("pictures/a/");print_r($pictures);[/code] Link to comment https://forums.phpfreaks.com/topic/27991-help-on-picture-manipulation/#findComment-128062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.