הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   בדיקת זמן, שימוש אחרון בקובץ PHP (https://hosts.co.il/forums/showthread.php?t=76417)

S-Preso 16-07-09 20:55

ציטוט:

נכתב במקור על ידי Baku (פרסם 727301)
אהה..
מצטער אחרי שסיימתי שיניתי כמה שמות לפונקציות כדי שיהיה יפה יותר.
להלן הקוד המתוקן:


PHP קוד:

<?php
/**
 * Getting Files By Modified time
 * 
 * @author Almog Baku
 * @link http://www.AlmogBaku.com
 *
 * @param string $dir         - Default: current direction
 * @return array() $files
 */
function get_files_byDate($dir="./") {
    
$list    _byDate_get_file_list($dir);
    
usort($list'_byDate_sorter');
    
    
$return = array();
    foreach (
$list as $value)
        
$return[] = $value['file'];
    
    return 
$return;
}
/**
 * Getting file list
 *
 * @param string $dir
 * @return array $list[]['time']['file']
 */
function _byDate_get_file_list($dir="./") {
    
$list    = array();
    
    if (
$handle opendir($dir)) {
        while ((
$file readdir($handle)) !== false) {
            if((
$file != ".") && ($file != "..")) {
                
$list[]    = array('time'=>filemtime($dir $file), 'file'=>$dir $file);
            }
        }
        
closedir($handle);
    }
    return 
$list;
}

/**
 * Sorter by `time` index of file list
 *
 * @param current $a
 * @param next $b
 * @return return before(-1) or after(+1)
 */
function _byDate_sorter($a$b) {
    if(
$a['time']<$b['time'])
        return -
1;
    else
        return 
1;
}

/**
 * @example 
 */
print_r(get_files_byDate());
?>

בקו.

אהלן, תודה אך לא הבנתי איך הקוד הזה קשור לנושא שלי?

AlmogBaku 16-07-09 21:08

האא לא קראתי טוב, אתה רוצה גישה אחרונה.
זה אותו דבר תחליף את הfilemtime בstat

S-Preso 17-07-09 14:25

ציטוט:

נכתב במקור על ידי Baku (פרסם 728276)
האא לא קראתי טוב, אתה רוצה גישה אחרונה.
זה אותו דבר תחליף את הfilemtime בstat

זה לא עוזר לי.

אשמח אם מישהו יוכל להמליץ לי על תוכנה שמסדרת את הקבצים לפי שימוש אחרון ויש אפשרות למחוק את הקבצים הישנים ביותר.

תודה!


כל הזמנים הם GMT +2. הזמן כעת הוא 09:53.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ