Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyświetlanie plików z katalogu..., tylko z wybranym rozszeżeniem :P
Lars
post
Post #1





Grupa: Zarejestrowani
Postów: 279
Pomógł: 15
Dołączył: 29.04.2005
Skąd: Gdynia

Ostrzeżenie: (0%)
-----


Mam skrypt:

  1. <?php
  2. $the_array=array();
  3. $handle=opendir($downloaddir);
  4. while(false !==($file=readdir($handle))) {
  5. if($file != '.' && $file !='..') {
  6. $the_array[]=$file;
  7. }
  8. }
  9. closedir($handle);
  10. sort($the_array);
  11. reset($the_array);
  12. while(list($key, $val)=each($the_array)) {
  13. echo '<a href=\"'.$downloaddir.'/'.$val.'\">'.$val.'</a>';
  14. }
  15. ?>


chce, aby wyświetlał tylko pliki z rozszeżeniem *.zip.
Jak to zrobić (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/happy.gif)

Ten post edytował Lars 5.07.2005, 18:36:51
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
crash
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


A poszukać na forum to nie łaska?!
  1. <?php
  2. $the_array = array();
  3. $handle = opendir( $downloaddir );
  4. while( false !== ( $file = readdir( $handle ) ) )
  5. {
  6.  if( strpos( $file, '.zip' ) !== false )
  7.  {
  8. $the_array[] = $file;
  9.  }
  10. }
  11.  
  12. closedir( $handle );
  13. sort( $the_array );
  14. reset( $the_array );
  15.  
  16. foreach( $the_array as $file )
  17. {
  18.  echo '<a href=\"'.$downloaddir.'/'.$file.'\">'.$file.'</a>';
  19. }
  20. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 20:27