Hej! Znalazłem gdzieś w przykładach taki skrypcik. Chciałbym by ten oto skrypcik pokazywał pliki w odwrotnej kolejności. Wiem, że trzeba coś zrobić z tablicą, ale nie za bardzo się na tym znam...
Teraz, gdy mam pliki x2.php, x11.php, x5.php, x24.php, x9.php, x13.php, x10.php, wyświetla mi je w kolejności:
-x.php
-x.php
-x.php
-x.php
-x.php
-x.php
-x.php
A ja bym chciał, by wyświetlił je w takiej:
-x.php
-x.php
-x.php
-x.php
-x.php
-x.php
-x.php
Aoto kod:
<?php
# Do we have a path? if not, it's the current directory
$path = $_GET[\"path\"];
if( !isset( $path ) || $path == \"\" ) { $path = \".\";
}
//# Print out for navigation
//print \"Current path: <b>\" . $path . \"</b><br />\";
# Initialise list arrays, directories and files separately and array counters fo
them
$d_arr = array(); $d = 0; $f_arr = array(); $f = 0;
# Open possibly available directory
while( false !== ( $file = readdir( $handle ) ) ) { # Make sure we don't push parental directories or dotfiles (unix) into the arrays
if( $file != \".\" && $file != \"..\" && $file[0] != \".\" ) {
if( is_dir( $path . \"/\" . $file ) ) # Create array for directories
$d_arr[$d++] = $file;
else
# Create array for files
$f_arr[$f++] = $file;
}
}
}
}
# Wrap things up if we're in a directory
# Sort and reset the arrays
# Print a parent directory link
print \"<a href=\"?path=\" . $d_prev . \"\"> Spis kategorii </a><br />n\";
# Print the directory list
for( $i=0; $i < count( $d_arr ); $i++ ) { # Print with query string
print \"<img border=/\"0/\" src=/\"../folder.gif/\" width=/\"16/\" height=/\"14/\"> <a href=\"?path=\" . $path . \"/\" . $d_arr[$i] . \"\">\" . $d_arr[$i] . \"</a>/<br />n\"; }
# Print file list
for( $i=0; $i < count( $f_arr ); $i++ ) { # Only print path and filename
print \"<img border=/\"0/\" src=/\"../img.gif/\" width=/\"14/\" height=/\"16/\"> <a href=\"\" . $path . \"/\" . $f_arr[$i] . \"\"> \" . $f_arr[$i] . \"</a>\"; # We may want a file size. NOTE: needs $path to stat
if( filesize( $path . \"/\" . $f_arr[$i] ) >= 1024 ) { # Size in kilobytes
print \" \" . round( filesize( $path . \"/\" . $f_arr[$i] ) / 1024, 1 ) . \" KB<br />n\"; } elseif( filesize( $path . \"/\" . $f_arr[$i] ) >= 1048576 ) { # Size in megabytes
print \" \" . round( filesize( $path . \"/\" . $f_arr[$i] ) / 1024 / 1024, 1 ) . \" MB<br />n\"; } else {
# Size in bytes
print \" \" . filesize( $path . \"/\" . $f_arr[$i] ) . \" bytes<br />n\"; }
}
?>
---

aleksander