electronish Posted December 16, 2006 Share Posted December 16, 2006 Using the following code I am able to get the files and folders , But i cannot access arrays . THis script gives me the files and their info like mtime , size etc But I want to comapre the timestamps to check for a new file and then copy it to different folder. How can I use the following code to compare the mtime between a file and the file previous to it. ? [code]<?php$dir = chdir('D:\MYvideos');function recur_dir($dir){ $dirlist = opendir($dir); while ($file = readdir ($dirlist)) { if ($file != '.' && $file != '..') { $newpath = $dir.'/'.$file; $level = explode('/',$newpath); if (is_dir($newpath)) { $mod_array[] = array( 'level'=>count($level)-1, 'path'=>$newpath, 'name'=>end($level), 'kind'=>'dir', 'mod_time'=>filemtime($newpath), 'content'=>recur_dir($newpath)); }else{ $mod_array[] = array( 'level'=>count($level)-1, 'path'=>$newpath, 'name'=>end($level), 'kind'=>'file', 'mod_time'=>filemtime($newpath), 'size'=>filesize($newpath)); counter(); } } } closedir($dirlist); return $mod_array;}function counter(){ global $count; $count = $count+1;}echo '<pre>';print_r(recur_dir('.'));echo '</pre>';print "total number of files are $count";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30853-pleasehelp-arrays/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.