I need that function to delete 10 minutes old files from my project,
remove_x_minutes_old_files function required two parameters $path for directory path and $in_minutes for minutes how much old file you want to delete.
function remove_x_minutes_old_files($path,$in_minutes=10){ $minutes_in_seconds = $in_minutes*60; $now_unix_time = strtotime('now'); $d2 = array('.','..'); $dirs = array_diff(scandir($path),$d2); foreach($dirs as $pathKey=>$pathVal){ $new_path =$path.$pathVal; if(is_dir($new_path)){ remove_ten_minutes_old_files($new_path.'/'); } else { if(($now_unix_time - filemtime($new_path) ) >=$minutes_in_seconds){ unlink($new_path); } } } }