Re: Opening Multiple Files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7 Sep 2011, at 15:21, Ron Piggott 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?
> 
> When the file is open I need the FOREACH (above) to parse the content which ends with an “INSERT INTO” for a mySQL table.

Look at the manual pages for glob and readdir - both will do what you need.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux