Re: PHP: Mulitiple Arrary Sort

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This may be a stupid question, but I am sick and under the guy and am wondering if you could you show me how to simply echo each file name using the exmaple below?

Thanks

"Jim Lucas" <lists@xxxxxxxxx> wrote in message news:48BEB36F.5010402@xxxxxxxxxxxx
Jim Lucas wrote:
ok, here would be my version of this code.

<pre><?php

$dir = './';
$filepattern = '*';
$sorting_list = array();
$filemtimes = array();

# Get file/dir listing, else error message
if ( ( $list = glob( $dir . $filepattern ) ) !== false ) {

foreach ( $list AS $file ) {

$filemtime = filemtime( $dir . $file );

# Build array to be sorted with filename and filemtime
$sorting_list[] = array('filename' => $file,
'filemtime' => $filemtime,
);

# This is the list of filemtimes to sort by later
$filemtimes[] = $filemtime;

}

# Sort array based on $filemtimes
# http://php.net/array-multisort     Example #3
if ( array_multisort($filemtimes, SORT_DESC, $sorting_list) ) {
echo "List was sorted by filemtime\n";
} else {
echo "List was not sorted by filemtime\n";
}

var_dump($sorting_list);

} else {

echo 'Directory listing call failed!';

}

?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux