Jump to content

Get contents of a dir, and echo the contents of the .htm files..?


ripkjs

Recommended Posts

Looking to grab the contents of a subdir and combine/append the contents of .htm files in that directory, and any new ones added, into one usable string. The .htm files will always be named with the 6 digit MMDDYY.htm, and maximum of only one per day (3-4per week in total). So I think that would eliminate the need to check the file date. I'd like to display the contents of the newest one on top, and descend as the dates get older. With scandir() I can get these files in an array (and in the correct order), but the first two keys are being taken up with "." and "..", and going beyond that, I'm not sure how to get the contents of the items in the array to display.

this should help get you started:

$dir = 'my directory';

$handle = opendir($dir);
$result = array();

while ( $listings = readdir($handle) )
{

if ( $listings != '.' && $listings != '..' )
{

if ( !preg_match("@^\d{6}.htm$@i", $filename) )
$result[] = $listings;

}

 

to display them:

foreach ($result as $r) {

echo '<li>' . $r . '</li>';

}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.