note 98753 deleted from function.glob by danbrown

From: Date: Mon, 05 Jul 2010 14:19:56 +0000
Subject: note 98753 deleted from function.glob by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170711@lists.php.net to get a copy of this message
Note Submitter: James ---- tailinchu[at]gmail[dot]com said: here is a quick fix when nothing matches, glob will return false $files=glob('*.txt')?glob('*.txt'):array(); The problem with that is that if something matches, the filesystem will be scanned twice - inefficient! Better is: $f = glob('*.txt'); $files=$f?$f:array();

« previous php.notes (#170711) next »