ironman32 Posted March 31, 2009 Share Posted March 31, 2009 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 More sharing options...
Ayon Posted March 31, 2009 Share Posted March 31, 2009 you could try and use if (!in_array()) { add to array } Link to comment https://forums.phpfreaks.com/topic/151852-array-list-problem/#findComment-797410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.