I'm pulling my hair, I'm just creating a bunch of different little experiments and little fun projects right now. I've got a Deal or No Deal thing that's going very well. I'm trying to create some XML/PHP dealies. And my last one is the where I hit a snag. I'm trying to create a Black Jack game, but my random number generator doesn't seem to be working right. Here's my code: {it's completely unfinished and I only started creating it.}
The reason I say it doesn't work is that everytime I refresh my page, it returns the same card. Every once in a while it changes, but that happens after a minute or so, so it's not helpful at all.PHP Code:session_start();
if(!isset($_SESSION['suite'])){
$_SESSION['suite'] = array("Hearts", "Diamonds", "Clubs","Spades");
}
if(!isset($_SESSION['number']))
{
$_SESSION['number'] = array("Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace");
}
if(!isset($_SESSION['cards']))
{
$_SESSION['cards'];
}
function showCard()
{
$suite = $_SESSION['suite'][rand(0, 3)];
$number = $_SESSION['number'] [rand(0, 12)];
return $number .' of '. $suite;
}
function addToCardsArray($card){
$_SESSION['cards'][] = $card;
}
echo '<form action="mypage.php">';
echo showCard() .'<br>';
echo showCard();
echo '</form>';




Reply With Quote