note 103527 added to function.filemtime

From: Date: Mon, 18 Apr 2011 17:08:53 +0000
Subject: note 103527 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-178948@lists.php.net to get a copy of this message
// THE BEST WAY TO GET the FILENAME OF THE LAST //MODIFIED FILE - THANK ME ! $newstamp = 0; $newname= ""; function dirTxt($dir1) { $d1=dir($dir1); while(false!== ($file1 = $d1->read())) { $extension1 = substr($file1, strrpos($file1, '.')); // Gets the File Extension if ($extension1==".txt") $logFiles[$file1]=$file1; } $d1->close(); return $logFiles; } //end of function $arrayLogFiles= dirTxt('path/to/file/'); foreach ($arrayLogFiles as $key1 => $text1) // Display filename { $timedat = filemtime($text1); if ($timedat > $newstamp) { $newstamp = $timedat; $newname = $text1; } } echo $newname; ---- Server IP: 69.147.83.197 Probable Submitter: 71.70.253.170 ---- Manual Page -- http://www.php.net/manual/en/function.filemtime.php Edit -- https://master.php.net/note/edit/103527 Del: integrated -- https://master.php.net/note/delete/103527/integrated Del: useless -- https://master.php.net/note/delete/103527/useless Del: bad code -- https://master.php.net/note/delete/103527/bad+code Del: spam -- https://master.php.net/note/delete/103527/spam Del: non-english -- https://master.php.net/note/delete/103527/non-english Del: in docs -- https://master.php.net/note/delete/103527/in+docs Del: other reasons-- https://master.php.net/note/delete/103527 Reject -- https://master.php.net/note/reject/103527 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178948) next »