iflycc Posted March 10, 2009 Share Posted March 10, 2009 I have managed to get 2 separate instances of randomization on the same page, with the same content. However because there are only 4 items being randomized it is possible to prevent them from duplicating each other? code: <?php $random[] = "<p><img src\"images/sub_nav_downloads.jpg\"><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic1.jpg\" width=\"83\" height=\"78\" class=\"floatleft\"></a>This hand carved stone statue was scanned by our Breuckmann SteroSCAN 6.6 mp scanner.</p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic2.jpg\" width=\"83\" height=\"72\" class=\"floatleft\"></a>View the incredible resolution and detail capable with white light scanning technology.<br></p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic3.gif\" width=\"83\" height=\"72\" class=\"floatleft\"></a>Approximately 3” in height, this small airfoil from a jet engine was scanned using our Breuckmann SmartScan 1.4 mega pixel.</p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic4.gif\" width=\"83\" height=\"72\" class=\"floatleft\"></a>This is an inspection report completed with PolyWorks IMInspect.</p>"; echo $random[rand(0,count($random)-1)]; ?> <p> </p> <?php $random[] = "<p><img src\"images/sub_nav_downloads.jpg\"><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic1.jpg\" width=\"83\" height=\"78\" class=\"floatleft\"></a>This hand carved stone statue was scanned by our Breuckmann SteroSCAN 6.6 mp scanner.</p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic2.jpg\" width=\"83\" height=\"72\" class=\"floatleft\"></a>View the incredible resolution and detail capable with white light scanning technology.<br></p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic3.gif\" width=\"83\" height=\"72\" class=\"floatleft\"></a>Approximately 3/” in height, this small airfoil from a jet engine was scanned using our Breuckmann SmartScan 1.4 mega pixel.</p>"; $random[] = "<p><a href=\"info_downloads.htm\"><img src=\"images/sub_nav_downloads_pic4.gif\" width=\"83\" height=\"72\" class=\"floatleft\"></a>This is an inspection report completed with PolyWorks IMInspect.</p>"; echo $random[rand(0,count($random)-1)]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/148805-randomizing-html-content-with-no-dupes/ Share on other sites More sharing options...
sasa Posted March 10, 2009 Share Posted March 10, 2009 look shuffle() function Quote Link to comment https://forums.phpfreaks.com/topic/148805-randomizing-html-content-with-no-dupes/#findComment-781406 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 You can use array_unique as well. Quote Link to comment https://forums.phpfreaks.com/topic/148805-randomizing-html-content-with-no-dupes/#findComment-790649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.