Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6593087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:38:14+00:00 2026-05-25T17:38:14+00:00

I have a game that will display ten random cards based on number and

  • 0

I have a game that will display ten random cards based on number and suit, but I need to check an array to see if the card has already been displayed. But my local array $card is not being saved when it passes through the function. Here is all my code for right now please try running it and tell me what I am doing wrong if you want the images they are avaiable at.

http://storealutes.com/blackjack/cards.zip

here is my php:

    <?php
                                     //suit 1=Clubs | 2=Hearts | 3=Spades | 4=Diamonds//
                                     //Color 1=1or11 | 2-10=#   | 11-12=10//
$number;
$suit;
$card = array();

function newcard($number,$suit,$card){

$arrsuit = array (clubs, hearts, spades, diamonds);
$arrnumber = array (a, 2, 3, 4, 5, 6, 7, 8, 9, 10, j, q, k);

$number = $arrnumber[rand(0,12)];                //Creates card value
$suit   = $arrsuit[rand(0,3)];       //Create card suit
$card   .= array  ($suit ." ". $number, hello);       //difines card name
return "<img src='cards/" . $suit . "-" . $number . "-150.png'/>";
}
for($i = 0; $i < 10; $i++){
echo newcard($number,$suit,$card);
}
echo $number;
foreach($card as $value){
    echo $value;
}


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:38:14+00:00Added an answer on May 25, 2026 at 5:38 pm

    To access a variable inside of a function use the follow techniques.

    $GLOBALS['card'][] = array  ($suit ." ". $number, hello);
    

    or

    global $card;
    $card[] = array  ($suit ." ". $number, hello);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop a game that will have to load jpg images that now i
We have a Silverlight 2 project (game) that will require a lot of character
We have a game that is very close to being released, but we have
I have a game engine that uses OpenGL for display. I coded a small
I am attempting to create a text-based adventure game for class, but I have
I have a game application that I will be running in a web browser
I'm trying to build an app that will display stats for a certain game
I have a game that currently runs under Windows and Mac OS X and
I have written a game that uses GLUT, OpenGL and FMOD. The problem is
If have I have a game engine that has multiple threads that all work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.