TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 05, 2024, 08:44:12 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,178
  • Total Topics: 21,220
  • Online today: 291
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 255
  • Total: 255

Tarot - 3 card spread

Started by evilicy, February 15, 2008, 02:23:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

evilicy

As the title says  :D On page refresh shows 3 random cards no dupes. Hold your mouse over each card for a brief description (uses rollovers).

Install:

1. Download and extract the major_arcana.zip and upload the folder to site root (or change paths) 
2. Download and extract the cards.dat.zip and upload to site root (or change paths)
3. In a php article / block <----  :uglystupid2: add the following code:


function random_card($cards)
{
// holds the last used card
static $exclude = array();
$max = count($cards) - 1;

$o = mt_rand(0, $max);

if(count($exclude) > 0)
{
while(array_search($o, $exclude) !== false)
{
$o = mt_rand(0, $max);
}
}
$exclude[] = $o;
return $cards[$o];
}
$file = file_get_contents('cards.dat');
// splits $file into an array
$cards = preg_split("/(\r\n|\n)/", $file, NULL, PREG_SPLIT_NO_EMPTY);

echo random_card($cards)."\n";
echo random_card($cards)."\n";
echo random_card($cards)."\n";


temp demo at:
http://www.darkvoid.org/test2.php

card images
cards.dat

Lord Anubis


evilicy

oops sorry about that. They are there now.

Lord Anubis

Thanks :)

Looks like a neat lil script