slots game

Created by Marfisa and explained by Rahenna. Please credit In the Cards if you use this script.

A common TCG game is Slots, which uses the PHP randomizer to show three different random images. The player refreshes the page until the three images match. In the past, members were usually asked to take a screenshot of the winning combination and to send it in by email or claim a prize on the forum. This automated version makes it much easier for the TCG owner.

This game can be integrated with Marfisa's randomizer - it's super easy! However, you don't need to be using her card randomizer to make this work.

This is a PHP game.
Your host must support PHP in order for you to use this game in your TCG.

get ready

Three simple steps will get you ready to add the slots game to your TCG!

1. Create a file named slots.php. Be sure to include any headers and footers you might be using.
2. Create your slots images. It doesn't matter how many there are.
3. Create a folder called slots on your site. Upload your slots images there.

set up the random images

Insert the following code into your slots.php. You can add as many files as you want; this example will have ten images named 01 to 10.gif. If you need to add more, be sure to include the comma after each image link! Note that there is no comma at the end of the LAST image link.


$slots = array (


If you are using Marfisa's randomizer, add the code above to your reward.php, but leave out <?php at the beginning and ?> at the end. You just want the stuff in between.

Okay, you're done setting up the random images!
What, were you expecting something harder? Sorry to disappoint! (If you've ever installed Wordpress yourself, this is funny. If not, you probably think I'm an idiot. Whatever. =p)

set up the randomizer

Now that the images are set up, here's how we make them appear in a row on the page.
Copy and paste!


$one= $slots[array_rand($slots,1)];
$two= $slots[array_rand($slots,1)];
$three= $slots[array_rand($slots,1)];

echo "<img src=\"/" . $one ."\">\n";
echo "<img src=\"/" . $two ."\">\n";
echo "<img src=\"/" . $three ."\">\n";


That's all! Seriously.

prize check

Finally, we'll check to see what images have come up and dispense a prize if appropriate. If you look carefully at the code, you can see that all it does is check if image one is the same as image two. If it is, it then checks to see if image two is the same as image three. If both conditions are true, then it means that all three images are the same, and a prize can be given!

You can give your Slots game a bit of a twist! In this example, 10.gif is a special image. When three of 10.gif come up, there is an additional prize given on top of the ordinary prizes.


if ($one==$two && $two==$three) {
      if ($one=="slots/10.gif") {


If you'd rather not have a special image, the code below just checks for any three in a row.


if ($one==$two && $two==$three) {


Booya. You now have an automated Slots game. For real. Enjoy!
Please remember to give credit to Marfisa and link back to In the Cards!

The hardest part will be getting your randomizer code formatted correctly. If you're using Marfisa's randomizer, you can contact us for help, but if you're using something else, sorry, you're on your own.