actually, here's the entire situation (I actually solved this problem another way, but I'm convinced it should work and I can't figure out why it doesn't).
This is in a class. The image in question is going to be replaced frequently, but will always be given the same name. There may be other images in the directory, but I'm only interested in the one for this purpose. The image type, however -and therefore, the extension- may vary. In part:
PHP Code:
//most code omitted for this example.
class photo{
private $image_path;
private $image_filename;
public function __construct($custom_path=NULL){
// use the user-defined image directory path if present, otherwise
// default path is {docroot}/photoclass/images/
$this->image_path = empty($custom_path) ? '/photoclass/images/' : $custom_path;
// I already know the path, so use glob() to determine image type
$find = glob($this->image_path.'filename.{gif,jpg,png}', GLOB_BRACE);
// *should* be only one match; use first result. need some error checking, I suppose.
$find = $find[0];
$this->image_filename = $find;
// then other stuff happens
}
}
I ended up working around this by using:
PHP Code:
$exts = array('gif','jpg','png');
foreach($exts as $ex){
if(file_exists($this->image_path.'filename.'.$ex)){
$this->image_filename = 'filename.'.$ex;
}
}
it'll work fine for this application, but I want to get glob() working too. I'd be quite disappointed if I can only look through directories I'm sitting underneath.
Bookmarks