Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> galeria 1 zdjecie
-Gość_fraksipon-
post
Post #1





Goście







czolem potrzebuje skrypt ktory bedzie losowo pokazywal jedno zdjecie na stronie z wybranego folderu pt: zdjecia
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%)
-----


  1. <?php
  2. $dir  = './New/';
  3. $exts = array( 'gif', 'jpg', 'jpeg', 'png' );
  4. $imgs = array();
  5.  
  6. if( $d = opendir( $dir ) )
  7. {
  8.    while( $f = readdir( $d ) )
  9.    {
  10.       $ext = explode( '.', $f );
  11.       $ext = array_pop( $ext );
  12.       if( in_array( strtolower( $ext ), $exts ) )
  13.       {
  14.          $imgs[] = $f;
  15.       }
  16.    }
  17.    closedir( $d );
  18. }
  19.  
  20. $img = $imgs[ array_rand( $imgs ) ];
  21.  
  22. echo '<img src="' .  $dir . $img . '" alt="' . $img . '"/>';
  23. ?>

A 5zł wrzuć do mojej forumowej skarbonki... (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
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: 26.12.2025 - 00:23