Page 2 of 2

Posted: Tue Mar 30, 2004 11:36 am
by pickle
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:

Code: Select all

$link = array_rand($image_array);
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]

Posted: Wed Mar 31, 2004 11:36 am
by jacka18l
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
"

Posted: Wed Mar 31, 2004 3:01 pm
by pickle
You're missing a semi colon.

Posted: Wed Mar 31, 2004 3:04 pm
by Zay
$images = array('http://www.com/image1.jpg','http://www. ... image3.jpg')
$link = array_rand($image_array);
and ehm... the varname for your array is $images... but you pass $image_array as parameter :S