note 81367 added to function.include
| From: | uramihsayibok at osu1 dot php dot net | Date: | Mon, 25 Feb 2008 01:28:38 +0000 |
| Subject: | note 81367 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136466@lists.php.net to get a copy of this message | ||
I have a need to include a lot of files, all of which are contained in one directory. Support for
things like <?php include_once 'dir/*.php'; ?> would be nice, but it doesn't
exist.
Therefore I wrote this quick function (located in a file automatically included by
auto_prepend_file):
<?php
function include_all_once ($pattern) {
foreach (glob($pattern) as $file) { // remember the { and } are necessary!
include $file;
}
}
// used like
include_all_once('dir/*.php');
?>
A fairly obvious solution. It doesn't deal with relative file paths though; you still have to
do that yourself.
----
Server IP: 209.41.74.194
Probable Submitter: 134.121.124.158
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/81367
Del: integrated -- https://master.php.net/note/delete/81367/integrated
Del: useless -- https://master.php.net/note/delete/81367/useless
Del: bad code -- https://master.php.net/note/delete/81367/bad+code
Del: spam -- https://master.php.net/note/delete/81367/spam
Del: non-english -- https://master.php.net/note/delete/81367/non-english
Del: in docs -- https://master.php.net/note/delete/81367/in+docs
Del: other reasons-- https://master.php.net/note/delete/81367
Reject -- https://master.php.net/note/reject/81367
Search -- https://master.php.net/manage/user-notes.php