Jump to content

Array list problem


ironman32

Recommended Posts

I have an array list which currently puts out data at random. What I would like is for it to output random data in an ordered list but not to have the same data appear more than once on the list

here is the code

 

<?php
srand((float) microtime() * 1000);
$input2 = array("<a href =\"http://www.muscleandstrength.com/exercises/barbell-bench-press.html\">Bench press</a>", 
"<a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">Military Press behind the neck</a>", 
"<a href=\"http://www.liverpoolfc.tv\">A</a>","<a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">C</a>",
"<a href =\"http://www.muscleandstrength.com/exercises/military-press-behind-neck.html\">B</a>",);

$rand_keys2 = array_rand($input1, 3);


?>

 

Here is the ordered list

<ol>
<li>Stretch/Warm up </li><br></br>
<li><?php echo $input2[$rand_keys[1]] . "\n"; ?></li>
<li><?php echo $input2[$rand_keys[2]] . "\n"; ?></li>
<li><?php echo $input2[$rand_keys[1]] . "\n"; ?></li>
<li><?php echo $input2[$rand_keys[2]] . "\n"; ?></li>
</ol>

 

Any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/151852-array-list-problem/
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.