note 98753 added to function.glob
| From: | James at osu1 dot php dot net | Date: | Mon, 05 Jul 2010 13:38:02 +0000 |
| Subject: | note 98753 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170710@lists.php.net to get a copy of this message | ||
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();
----
Server IP: 69.147.83.197
Probable Submitter: 195.97.237.246
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/98753
Del: integrated -- https://master.php.net/note/delete/98753/integrated
Del: useless -- https://master.php.net/note/delete/98753/useless
Del: bad code -- https://master.php.net/note/delete/98753/bad+code
Del: spam -- https://master.php.net/note/delete/98753/spam
Del: non-english -- https://master.php.net/note/delete/98753/non-english
Del: in docs -- https://master.php.net/note/delete/98753/in+docs
Del: other reasons-- https://master.php.net/note/delete/98753
Reject -- https://master.php.net/note/reject/98753
Search -- https://master.php.net/manage/user-notes.php