Jump to content

[SOLVED] rand()


eRott

Recommended Posts

Hey,

 

Okay, I have an array containing a bunch of links and a script which pulls out of one these random links and echo's it. However, I am having a bit of trouble. I need to pull 4 of them at a time and I cannot pull any one of them more then once. Any idea's? I'm thinking of a while loop or something similar. Thanks and take care.

 

<?php
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";
$tags[] = "<a href=\"#\" class=\"#\"></a>";

$tag_count = count($tags) - 1;
$tag = $tags[rand(0,$tag_count)];

echo '<li>'.$tag.'</li>';
?>

Link to comment
https://forums.phpfreaks.com/topic/105684-solved-rand/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.