PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Tue Mar 30, 2004 11:36 am
Illusionist wrote: so you have an array of links to images??
Code: Select all
$images = array('http://www.com/image1.jpg','http://www.com/image2.jpg','http://www.com/image3.jpg')
If that's the case, do this:
If you're running on a PHP version earlier than 4.2, you're going to need to seed the random number generator as well.
[php_man]array_rand[/php_man]
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
jacka18l
Forum Newbie
Posts: 6 Joined: Sun Mar 21, 2004 1:12 pm
Post
by jacka18l » Wed Mar 31, 2004 11:36 am
yes like that,
but now i cant get it to work
Code: Select all
<?
$images = array('http://www.com/image1.jpg','http://www.com/image2.jpg','http://www.com/image3.jpg')
$link = array_rand($image_array);
?>
is that right?
i keep getting this error
"Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\Abyss Web Server\htdocs\****\****.php on line 3
"
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Wed Mar 31, 2004 3:01 pm
You're missing a semi colon.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Zay
Forum Newbie
Posts: 22 Joined: Tue Mar 23, 2004 3:42 pm
Post
by Zay » Wed Mar 31, 2004 3:04 pm
and ehm... the varname for your array is $images... but you pass $image_array as parameter :S