Jump to content

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


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>';

}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.