php print problem

  • jamesbond
  • Novice
  • Novice
  • jamesbond
  • Posts: 20

Post 3+ Months Ago

Im tring to make a simple poker php program and the cards are labeled 2d.gif 3d.gif and so on (2 diamonds 3 diamonds)
and i have them sorted into two arrays and one for cards and one for suits but im having trouble makeing them print
Code: [ Select ]
<body>
<h1>Poker Tourment</h1>
<br>
</center>
<?php
$cards = array('a','1','3','4','5','6','7','8','9','10','j','q','k');
$suits = array('c','d','h','s');
$rand_keys = array_rand($cards,2);
$rand_keys = array_rand($suits,2);
for($i=0;i<=5;$i++){
print "<img src =\"$cards$suits.gif\" alt = \"$cards$suits.gif\"/>"; 
}
?>
<button type = "submit">Deal</button><br>
<a href="poker.php">Play again</a>
</body>
  1. <body>
  2. <h1>Poker Tourment</h1>
  3. <br>
  4. </center>
  5. <?php
  6. $cards = array('a','1','3','4','5','6','7','8','9','10','j','q','k');
  7. $suits = array('c','d','h','s');
  8. $rand_keys = array_rand($cards,2);
  9. $rand_keys = array_rand($suits,2);
  10. for($i=0;i<=5;$i++){
  11. print "<img src =\"$cards$suits.gif\" alt = \"$cards$suits.gif\"/>"; 
  12. }
  13. ?>
  14. <button type = "submit">Deal</button><br>
  15. <a href="poker.php">Play again</a>
  16. </body>


Im just tring to get it to deal 5 random cards for now
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

I would use a single 52 element array for a deck. Then randomly pluck cards from that deck using splice/slice/lcg_value and adding them to an array of hands.
  • jamesbond
  • Novice
  • Novice
  • jamesbond
  • Posts: 20

Post 3+ Months Ago

how do you get the for loop to print on one line left to right ?
  • jamesbond
  • Novice
  • Novice
  • jamesbond
  • Posts: 20

Post 3+ Months Ago

you can close this i figured it out (used a css div)

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 90 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.