Results 1 to 2 of 2

Thread: @reg random images

  1. #1
    Junior Member v-eee's Avatar
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Talking @reg random images

    hi all...
    im request random images in directory and sub directory..
    thx.

  2. #2
    Senior Member something else's Avatar
    Join Date
    Feb 2008
    Location
    if($something){echo 'Status code 404'; }else{ echo 'coding-talk.com';}
    Posts
    1,817
    Thanks
    209
    Thanked 446 Times in 201 Posts
    Rep Power
    0

    Default

    PHP Code:
    <?
     $imglist
    ='';
      
    //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
    // see that you don't forget about the "/" at the end 
     
    $img_folder "images/tutorials/";

      
    mt_srand((double)microtime()*1000);

      
    //use the directory class
     
    $imgs dir($img_folder);

      
    //read all files from the  directory, checks if are images and ads them to a list (see below how to display flash banners)
     
    while ($file $imgs->read()) {
       if (
    eregi("gif"$file) || eregi("jpg"$file) || eregi("png"$file))
         
    $imglist .= "$file ";

     } 
    closedir($imgs->handle);

      
    //put all images into an array
     
    $imglist explode(" "$imglist);
     
    $no sizeof($imglist)-2;

     
    //generate a random number between 0 and the number of images
     
    $random mt_rand(0$no);
     
    $image $imglist[$random];

    //display image
     
    echo '<img src="'.$img_folder.$image.'" border=0>';
     
    ?>
    Taken From:
    [Only registered and activated users can see links. Click Here To Register...]

    Looks an old script may need to replace eregi with preg_match (but thats entirely up to you) :P
    Last edited by something else; 22-07-11 at 11:05.

    [Only registered and activated users can see links. Click Here To Register...]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Show Random ads (random text+random title)
    By morency in forum Snippets, Functions and Classes
    Replies: 5
    Last Post: 02-03-11, 02:43
  2. Tag images
    By robzky in forum Coding Forum
    Replies: 7
    Last Post: 05-08-10, 19:34
  3. generate random password/random string
    By GumSlone in forum Snippets, Functions and Classes
    Replies: 1
    Last Post: 18-07-10, 19:18
  4. Help With Images
    By SpiderWap in forum Coding Forum
    Replies: 2
    Last Post: 14-05-08, 17:35
  5. Mood Images
    By matttty in forum Site / Script testing and error fixing
    Replies: 2
    Last Post: 28-12-07, 18:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19