note 94809 added to function.glob
| From: | jason at barkingsnake dot com | Date: | Thu, 26 Nov 2009 00:09:08 +0000 |
| Subject: | note 94809 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163293@lists.php.net to get a copy of this message | ||
re:
>> here is a quick fix when nothing matches, glob will return false
>> <?php $files=glob('*.txt')?glob('*.txt'):array(); ?>
>> now you are able to use array function to $files.
Try this instead:
<?php $files = (array) glob('*.txt'); // forces empty array on fail ?>
----
Server IP: 64.71.164.2
Probable Submitter: 173.196.3.190
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/94809
Del: integrated -- https://master.php.net/note/delete/94809/integrated
Del: useless -- https://master.php.net/note/delete/94809/useless
Del: bad code -- https://master.php.net/note/delete/94809/bad+code
Del: spam -- https://master.php.net/note/delete/94809/spam
Del: non-english -- https://master.php.net/note/delete/94809/non-english
Del: in docs -- https://master.php.net/note/delete/94809/in+docs
Del: other reasons-- https://master.php.net/note/delete/94809
Reject -- https://master.php.net/note/reject/94809
Search -- https://master.php.net/manage/user-notes.php