我有这样的代码到目前为止它完美,但依赖于有被替代的目录:检查目录是否存在,如果它不选择一个图像
$path = '/home/sites/therealbeercompany.co.uk/public_html/public/themes/trbc/images/backgrounds/'.$this->slug;
$bgimagearray = array();
$iterator = new DirectoryIterator($path);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile() && !preg_match('\.jpg$/', $fileinfo->getFilename())) {
$bgimagearray[] = "'" . $fileinfo->getFilename() . "'";
}
}
我需要在顶部,所以在有些工作如果目录不存在,它默认为位于后台目录根目录的图像...
任何帮助,将不胜感激。
谢谢你的帮助 – Andy 2010-03-27 16:42:25
is_dir在什么都没有的情况下工作吗? – Powertieke 2010-03-27 16:49:38