Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Random Images X 4 [solved]

edited May 2007 in Vanilla 1.0 Help
I'm writing a PHP script that displays 4 random images (with links) and displays them in a 2 x 2 table like this.

Anyone have any sample scripts?

The main problem stumping me is that the random pics need to be selected randomly at the same time to avoid duplicates.

Posted: Thursday, 10 May 2007 at 8:28PM


  • Options
    Cant you just select them at different times but make sure they havent been selected before? Run through a loop to select them and when one has been chosen add it to an array then check the selected image isnt in the array in future?
  • Options
    OK, that sounds like a plan, any examples?

    Posted: Thursday, 10 May 2007 at 8:40PM

  • Options
    $image = array();
    for ($i = 1; $i <= 4; $i++) {
    $newimage = SELECT RANDOM IMAGE;
    while (in_array($newimage,$image)) {
    $image[$i] = $newimage

    That's quickly thrown together in the middle of a busy workday and untested but you should get the jist..?
  • Options
    Thanks Minisweeper, your sample was a little cryptic considering my novice level with PHP but I am a tenacious bugger, I solved the problem.

    Posted: Sunday, 13 May 2007 at 8:43PM

This discussion has been closed.