note 88649 added to function.filemtime

From: Date: Mon, 02 Feb 2009 11:22:32 +0000
Subject: note 88649 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-150093@lists.php.net to get a copy of this message
Filemtime seems to return the date of the EARLIEST modified file inside a folder, so this is a recursive function to return the date of the LAST (most recently) modified file inside a folder. <?php // Only take into account those files whose extensions you want to show. $allowedExtensions = array( 'zip', 'rar', 'pdf', 'txt' ); function filemtime_r($path) { global $allowedExtensions; if (!file_exists($path)) return 0; $extension = end(explode(".", $path)); if (is_file($path) && in_array($extension, $allowedExtensions)) return filemtime($path); $ret = 0; foreach (glob($path."/*") as $fn) { if (filemtime_r($fn) > $ret) $ret = filemtime_r($fn); // This will return a timestamp, you will have to use date(). } return $ret; } ?> ---- Server IP: 130.206.1.5 Probable Submitter: 80.25.157.230 ---- Manual Page -- http://www.php.net/manual/en/function.filemtime.php Edit -- https://master.php.net/note/edit/88649 Del: integrated -- https://master.php.net/note/delete/88649/integrated Del: useless -- https://master.php.net/note/delete/88649/useless Del: bad code -- https://master.php.net/note/delete/88649/bad+code Del: spam -- https://master.php.net/note/delete/88649/spam Del: non-english -- https://master.php.net/note/delete/88649/non-english Del: in docs -- https://master.php.net/note/delete/88649/in+docs Del: other reasons-- https://master.php.net/note/delete/88649 Reject -- https://master.php.net/note/reject/88649 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150093) next »