Revision: 52273
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 18, 2011 13:40 by klovera
Initial Code
function getImages($folder){ $basedir = "/home/cochipp/public_html/"; // base directory for the server $localdir = "images/banners/".$folder."/"; // local directory and the folder passed $dirname = $basedir.$localdir; $dir = opendir($dirname); $images_arr = array(); $images = ""; $i = 0; while(false != ($file = readdir($dir))){ if(($file != ".") and ($file != "..") and ($file != "index.html")){ $images_arr[$i] = '{ src: "/'.$localdir.$file.'" },'; $i++; } } shuffle($images_arr); foreach($images_arr as $image){ $images .= $image; } // strip off last comma $images = substr($images, 0, -1); echo $images; }
Initial URL
Initial Description
Returns all the images in a folder randomly.Listed back in this format: { src: "/'.$localdir.$file.'" },
Initial Title
function: getImages($folder)
Initial Tags
Initial Language
PHP