Using variable on a separate page

I have a directory listing in PHP. I want to be able to display the date of the last modified file in there, on another page. If I sort the array and get filemtime, would it be possible to put this in a variable and have it be referenced in another page’s php? If not, how would I go about obtaining this?

I do not know anything about PHP, so please forgive if this is a silly question.

I hope this was what you want 8)


$handle = opendir('.');

while (false !== ($file = readdir($handle))) {

	if (is_file($file)) {

        $modified = filemtime($file);
        $files[$modified] = $file;




$_SESSION['recent_file'] = array_shift($files);

echo $_SESSION['recent_file'];


If you want to keep a log of this and have a reference. The best way is to submit this info to mysql. You can keep many records there.

Sponsor our Newsletter | Privacy Policy | Terms of Service