11-07-09, 20:42
# 9
חבר מתקדם
מיני פרופיל
תאריך הצטרפות: Oct 2007
גיל: 35
הודעות: 689
ציטוט:
נכתב במקור על ידי
Baku
בשבילך-
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 = 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 ());
?>
תודה אבל לא פועל...