nasıl i php tarafından listelenen dosyaları sıralamak yok

0 Cevap php

benim sonuç nasıl sıralayabilirsiniz biraz karıştı im. Im bir dizindeki dosyaların bir listesini geri dönen ve bir şekilde sıralanması için onlara ihtiyacımız var ...

// Start directory
getDirectory('../gallery/photos');

function getDirectory( $path = '.', $level = 0 ){

 // Directories to ignore when listing output. 
 $ignore = array( '.', '..' ); 

 // Open the directory to the handle $dh
 $dh = @opendir( $path ); 

 // Loop through the directory 
 while( false !== ( $file = readdir( $dh ) ) ) {

  // Change filename to display date
  $displaydate= date('jS M Y', strtotime($file)); 

  // Check that this file is not to be ignored 
  if( !in_array( $file, $ignore ) ) { 

   // Indent spacing for better view
   $spaces = str_repeat( ' ', ( $level * 5 ) );

   // Show directories only
   if(is_dir( "$path/$file" ) ){ 

    // Re-call this same function but on a new directory. 
    // this is what makes function recursive. 
    echo "$spaces<a href='$path/$file'>$displaydate</a><br />";
    getDirectory( "$path/$file", ($level+1) ); 
   } 
  } 
 }
 // Close the directory handle 
 closedir( $dh ); 
} 

Burada i sıralama işlevi geçerli olacak?

teşekkürler

0 Cevap