Current location: Hot Scripts Forums » General Community » Script Requests » Image rotator shuffler

Image rotator shuffler

Reply
  #1 (permalink)  
Old 07-10-09, 04:00 AM
watermelon watermelon is offline
New Member
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Image rotator shuffler

Hello everyone, Ive got a random image rotator script that works but i feel that i keep getting a lot of the same images and never see some images. I was wondering if its possible to have a random image rotator that goes through every image in the directory in a random order before showing the same picture again.

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-10-09, 04:13 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,508
Thanks: 3
Thanked 11 Times in 11 Posts
Post your code, please.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-10-09, 04:27 AM
watermelon watermelon is offline
New Member
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:
<?php 

//read folder
$folder=opendir("."); 
while (
$file readdir($folder)) 
$names[count($names)] = $file
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar=0;
for (
$i=0;$names[$i];$i++){
$ext=strtolower(substr($names[$i],-4));
if (
$ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;}
}
//random
srand ((double) microtime() * 10000000);
$rand_keys array_rand ($names12);
//random image from array
$slika=$names1[$rand_keys[0]]; 
//image dimensions
$dimensions GetImageSize($slika); 
if (isset(
$HTTP_GET_VARS["pic"])){header ("Location: $slika");}
else {echo 
"<img src=\"$slika\" $dimensions[3]>";
echo 
"<br>$slika<br>";
}
?>

Last edited by Nico; 07-10-09 at 04:30 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP & MYSQL Same Table Ishmell PHP 7 06-29-09 12:36 AM
div css theighost CSS 11 09-14-08 03:30 AM
displaying text over image ketanco CSS 10 09-11-08 08:39 PM
searching image nurqeen PHP 4 07-09-05 10:35 AM
how to draw an image inside a table? davidklonski HTML/XHTML/XML 2 07-06-04 11:27 AM


All times are GMT -5. The time now is 01:23 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.