Re: Opening Multiple Files
| From: | Tim Streater | Date: | Wed, 07 Sep 2011 14:33:00 +0000 |
| Subject: | Re: Opening Multiple Files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-314740@lists.php.net to get a copy of this message | ||
On 07 Sep 2011 at 15:21, Ron Piggott <ron.piggott@actsministries.org> wrote:
> Hi Everyone
>
> I am trying to load an HTML book into mySQL. The book was distributed with
> each chapter being it’s own HTML file.
>
> The only way I know how to open a file is by specifying the file name. Such
> as:
>
> $myFile = "B01C001.htm";
> $lines = file($myFile);
> foreach ($lines as $line_num => $theData) {
>
> Is there a way PHP will open each file in the directory ending in “.htm”,
> one file at a time, without me specifying the file name?
You can use opendir() and readdir() to get the filenames one by one.
--
Cheers -- Tim