Groups | Search | Server Info | Keyboard shortcuts | Login | Register
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | alt.php |
| Subject | Re: get pages age |
| Date | 2017-07-10 07:00 +0200 |
| Message-ID | <esgfunF3a9mU1@mid.individual.net> (permalink) |
| References | <afr32o.o3c.19.1@news.alt.net> |
On 07/10/17 01:17, Ed Mullen wrote:
> So, let's say we have a site with x pages and we would like to create a
> list of the pages ordered by their last modified date.
>
> How to do using any method, maybe PHP.
>
> BTW, each page on the site contains this footer code:
>
> <?php
> $current_file_name = ($_SERVER['REQUEST_URI']);
> $current_path = ($_SERVER['DOCUMENT_ROOT']);
> $full_name = $current_path.$current_file_name;
> $last_modified = filemtime($full_name);
> print("This page last changed: ");
> print(date("F j, Y - h:i A", $last_modified));
> print(" USA Eastern Time");
> ?>
>
> which displays the last modified date of each page. Not sure if that
> even is relevant.
>
I'm assuming that your pages are including all the content which is
static instead of fetching the dynamic data from a database.
Then you need to begin with list all the pages, you can use the dir()
function ( http://php.net/manual/en/function.dir.php ) and get the
filetime() for each file, store those in an array with the time in
unixtime as the key and the filename as the value, this requires that
each file has it's unique time, or else you need to have an array of
file names instead of a single value. Then user ksort (
http://php.net/manual/en/function.ksort.php ) to sort the values, use
the numeric sorting.
--
//Aho
Back to alt.php | Previous | Next — Previous in thread | Next in thread | Find similar
get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-09 19:17 -0400
Re: get pages age "J.O. Aho" <user@example.net> - 2017-07-10 07:00 +0200
Re: get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-10 10:43 -0400
Re: get pages age robamman2019@gmail.com - 2019-12-19 04:44 -0800
csiph-web