Jump to content

mt_rand doesn't work


wesley

Recommended Posts

Hello,

 

I have written a function in php. If you refresh the page you see a another image, but this doesn't work.

Now I see the 4 images in the browser.

 

Can someone help me what is wrong, why didn't work mt_rand?

 

thanks in advance.

function photorandom() {    $photo = array("www.google.nl" => "1.jpg", "www.bing.com" => "2.jpg", "3.jpg", "4.jpg");        $random = mt_rand(0, (count($photo)-1));     $randomImage = $photo[$random];        foreach($photo as $link => $randomImage) {    echo "<a href='http://{$link}'><img src=' {$randomImage} ' width='500'></a>";     }        }photorandom();
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...