Happy New Year!
I use the following function to pull a random image to put on a page through an included file:
Code: Select all
function ranget($path = '/random', $type)
{
$files = glob($path . $type);
$file = array_rand($files);
return $files[$file];
}
I access the function like this:
Code: Select all
$ranpic = "http://".$_SERVER['HTTP_HOST'].substr(ranget($_SERVER['DOCUMENT_ROOT']."/random/main",'/*.??g'),28);
I found it necessary to use the substr in order to get glob to find the directory. It works on my live site but on my local computer I get an error. I think this is because the path length of the file location on my local file is different from the one on the live site. It must have something to do with php and relative paths. Does anyone know anything about relative paths and php? I would like to be able to get everything to work both on my actual site and my local computer. Thanks