Hello all,

I have a php script but want to add some more features but I got stock.
I hope somebody can help me cause I'm a beginner in php.

The php script so far show all files in the root dir and subdirs in descending order of last modified so the newest is on top eg.

page02.php
Last Modified on Monday 04 april 2011 - 16:02:05
6 minutes, 45 secondes ago

page01.php
Last Modified on Sunday 03 april 2011 - 15:31:01
1 days, 37 minutes, 49 secondes ago

etc...

Now my question: I also want to show the page title name eg.

Members - page02.php
Last Modified on Monday 04 april 2011 - 16:02:05
6 minutes, 45 secondes ago

Start - page01.php
Last Modified on Sunday 03 april 2011 - 15:31:01
1 days, 37 minutes, 49 secondes ago

etc...

This is de code so far

<?php
function LoadFiles($dir,$filter="")
{
	#Set time and language
	setlocale(LC_ALL, 'nld_nld');

	date_default_timezone_set('Europe/Brussels');

	$hide = array(".", "..","config.php","settings.php","admin.php");
	$Files = array();
 
	$It =  opendir($dir);
	if (! $It)
	die('Cannot list files for ' . $dir);
	
	while ($Filename = readdir($It))
	{
		if ($Filename != '.' && $Filename != '..')
		{
			if(is_dir($dir . $Filename))
				{
					$Files = array_merge($Files, LoadFiles($dir . $Filename.'/'));
				}
		else 
		
		if ($filter=="" && $Filename == !in_array($Filename, $hide) && (preg_match("/\\.php$/", $Filename) || preg_match("/\\.html$/", $Filename) || preg_match("/\\.htm$/", $Filename)) ) 
		{
			$LastModified = filemtime($dir . $Filename);
			$Files[] = array($dir .$Filename, $LastModified);
		}
		
		else 
		continue;
		}
	}
	return $Files;
}

	function DateCmp($a, $b)
	{
	  return  strnatcasecmp($a[1] , $b[1]) ;
	} 

	function SortByDate(&$Files)
	{
	  usort($Files, 'DateCmp');
	  krsort($Files);
	} 

	$Files = LoadFiles("./");
	SortByDate($Files);
	reset($Files);
	while (list($k,$v) =each($Files))
		{
?>
		<table><tr><td>Real Title Page Show Here - <a href="<?=$v[0]?>"><?=$v[0]?></a></td></tr><tr><td>Laatst gewijzigd op <?= strftime ('%A %d %B %Y - %X',$v[1])?><br />&nbsp;</td></tr></table>
<?
		} 
?>

I hope somebody can help me out here with the extra code.
Thanks in advance.
Kind regards

i see 3 solutions

1 fopen each file and readout the <title> atrebute
-This probley makes your script to slow to be use full

2 put the tilte and the filenames in an array and
- if you want to add a new file u also have to edit your script

3 rename your files ea page1.php --> members.php than echo the filename without .php

Hello pzuurveen

Thanks for your reply but as a beginner it's real difficult to do that.
Option 3 doesn't seem the right one for me cause I name my pages that way I can easily find them.
Can you help me with option 2 and add the code into my posted script ?

Thanks in advance
Kind regards
Coderunner

Nobody who can help me ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.