note 103022 added to function.glob
| From: | Ultimater at gmail dot com | Date: | Mon, 21 Mar 2011 07:44:27 +0000 |
| Subject: | note 103022 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178038@lists.php.net to get a copy of this message | ||
glob() isn't limited to one directory:
<?php
$results=glob("{includes/*.php,core/*.php}",GLOB_BRACE);
echo '<pre>',print_r($results,true),'</pre>';
?>
Just be careful when using GLOB_BRACE regarding spaces around the comma:
{includes/*.php,core/*.php} works as expected, but
{includes/*.php, core/*.php} with a leading space, will only match the former as expected but not
the latter
unless you have a directory named " core" on your machine with a leading space.
PHP can create such directories quite easily like so:
mkdir(" core");
----
Server IP: 192.41.42.26
Probable Submitter: 76.90.130.197
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/103022
Del: integrated -- https://master.php.net/note/delete/103022/integrated
Del: useless -- https://master.php.net/note/delete/103022/useless
Del: bad code -- https://master.php.net/note/delete/103022/bad+code
Del: spam -- https://master.php.net/note/delete/103022/spam
Del: non-english -- https://master.php.net/note/delete/103022/non-english
Del: in docs -- https://master.php.net/note/delete/103022/in+docs
Del: other reasons-- https://master.php.net/note/delete/103022
Reject -- https://master.php.net/note/reject/103022
Search -- https://master.php.net/manage/user-notes.php