Welcome to Gaia! ::

Myspoonistoobig's avatar
  • 100
  • 100
  • 100
Peng
R A M Z A
Androphobia
How about random text signatures (like off of cutandpastescripts)? I would like to do that, but it has yet to work. XP
random text runs off of javascript...
the only way to have random text woud be to make the text in an image...
then add it to a random image script


Or you could do some fancy PHP that would make a randomly-picked string of text into an image.


Either way, this may have been mentioned already, but I had to change Ag2S03's code a bit to get it to work right:

<?php
$links = array(
"images",
"more images.jpg",
"blahblah.gif",
"myimage.png")

$howMany = count($links) -1; // number of images to randomize

srand ((double) microtime() * 948625) // seed the randomizer
$randNumber = rand(0,$howMany) // make the random Number

//select the image
header("Location: ".$links[$randNumber])
?>


I had to make it subtract one from $howMany, and then make the minimum number rand could pick be zero instead of one. Otherwise the first image wouldn't ever show, and sometimes it would output absolutely nothing.


all of those lines are unnecessary anyway.....PHP has array_rand() to pick a random element from an array. and as of php 4.2 (long time ago), you don't need to seed the random number generator

so really, it can be shortened to this:


<?php
$links = array("images","more images.jpg","blahblah.gif","myimage.png")
header('Location: ' . array_rand($links))
?>
Myspoonistoobig
all of those lines are unnecessary anyway.....PHP has array_rand() to pick a random element from an array. and as of php 4.2 (long time ago), you don't need to seed the random number generator

so really, it can be shortened to this:


<?php
$links = array("images","more images.jpg","blahblah.gif","myimage.png")
header('Location: ' . array_rand($links))
?>


If I didn't seed the random number generator, it wasn't very random. Like it would show the same image three or four times in a row. confused

But it can be shortened that much? Cool. smile

Edit: That didn't work. razz It just tried to redirect to a random number in the directory the script was in, not the image 'assigned' that number. (IE it would redirect to http://www.domain.com/sig/7 instead of http://www.domain.com/sig/image7.png.) This works, though, and it feels a bit faster than the old code:

<?php
$links = array("images","more images.jpg","blahblah.gif","myimage.png")
$randNum = array_rand($links)
header("Location: ".$links[$randNum])
?>


Edit: Just out of curiosity, I tried this, and it worked, too:

<?php
$links = array(
"image.png",
"other-image.jpg",
"blahblah.gif",
"myimage.png"
)
header("Location: ".$links[array_rand($links)])
?>
*bumps the thread*

Must...get...stickied...eventually... gonk domokun
Thats really handy, thanks 3nodding
Hmm..I can't get to blackfire...I hope it comes back soon.
Myspoonistoobig's avatar
  • 100
  • 100
  • 100
@peng: oh yeah. oops, little mistake there sweatdrop
Yeah.

For some reason black fire isn't working.

Is the site down or something? sweatdrop
err...i was told to come to this thread with my problem so...
i have a rotating image script with a single sigmap. the rotating images are a bunch of pets and my sigmap. the pets are showing up, but not the sigmap. i dont know whats wrong..perhaps someone here knows...heres the code..

Quote:
<?php
$links = array(
"http://img.photobucket.com/albums/v451/leatrix/ImageMaps/mapstary.jpg",
"http://img.photobucket.com/albums/v451/leatrix/pets/ryukogrown1.jpg",
"http://img.photobucket.com/albums/v679/Gauze-Mizin/kyegg.jpg",
"http://img.photobucket.com/albums/v679/Gauze-Mizin/mitsukiegg.jpg" wink ;

$howMany = count($links); //4

srand ((double) microtime() * 948625); //seed the randomizer
$randNumber = rand(1,$howMany); //make the random Number

//select the image
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
header("Location: ".$links[$randNumber]);
?>


and the code for my sig


User Image - Blocked by "Display Image" Settings. Click to show.
Now let's see if I got it right. xp
I can't get it to work. crying
Black Fire nor Cut and Paste scripts are working for me.

They both just get stuck on one image.
I used blackfire and its working great, thank you so much for this thread. smile
This has been bookmarked whee
Rika Lotus:

I can't really help you, but why do you have the header line there seven times? I see no point of doing that.... confused

....Wait, the image that's not showing up is the first one? See my previous posts in this thread for how to fix it. 3nodding

Quick Reply

Submit
Manage Your Items
Other Stuff
Get Items
Get Gaia Cash
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff