Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php if 2 files in dir unlink the olderst

<?php
    $directory = ".";

    $files = array();
    foreach(scandir($directory) as $file){
        if(is_file($file)) {

            //get all the files
            $files[$file] = filemtime($file);
        }
    }

    //sort descending by filemtime;
    arsort($files);
    $count = 1;
    foreach ($files as $file => $time){
        if($count > 10){
            unlink($file);
        }
        $count++;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress codex get post type woocommerce products 
Php :: content for php.ini created manually 
Php :: When I try to run my code in chrome, i see the code that I have made in phpstorm and not the function that it has to do 
Php :: call a class in another class php 
Php :: wp woocommerce change product tags to checbox 
Php :: Best version control tools for php 
Php :: afosto/yaac error parsing certificate request 
Php :: Class PHPUnit_Util_Log_TeamCity does not exist 
Php :: yii2 has many where 
Php :: select query with multiple where clause in php 
Php :: get current tax page 
Php :: wp+get author box in dashboard 
Php :: The video failed to upload video in laravel in cpanel 
Php :: php check if string startswith 
Php :: same name selection in phpstorm mac 
Php :: api key for getting youtube channel videos in php 
Php :: PHP strncasecmp — Binary safe case-insensitive string comparison of the first n characters 
Php :: laravel store file specifiying name and disk 
Php :: php 7.1 functions parameters with "?" 
Php :: Writing into the database with one click laravel 
Php :: default password when you make users in laravel 
Php :: display woocommerce review using specific id 
Php :: install wget downloader php 
Php :: apagar windows desde consola 
Php :: cara looping abjad with array 
Php :: .phtml 
Php :: import csv in laravel 
Php :: rerender block in twig 
Php :: openclassroom php 
Php :: phpunit 7 requirement php 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =