PHP Classes

echo card

Recommend this page to a friend!

      Poker Texas Hold'em Evaluation  >  All threads  >  echo card  >  (Un) Subscribe thread alerts  
Subject:echo card
Summary:short name and suit
Messages:2
Author:Marek Miglinski
Date:2010-04-01 22:04:49
Update:2010-10-29 07:32:54
 

  1. echo card   Reply   Report abuse  
Picture of Marek Miglinski Marek Miglinski - 2010-04-01 22:04:49
I'm trying to echo the short name and suit but I have no luck.

I type:
print_r ($arrPlayer[0]);
and see following:
Card Object ( [id] => 43 [name] => five [suit] => spades [value] => 5 [short] => 5 [pth] => 5 [suit_2] => s [short_2] => 5 )
Ok, now I type:
echo $arrPlayer[0]['short'];
And I receive an error message:
Fatal error: Cannot use object of type Card as array in
...default.php on line 33

So how to echo short name and suit?

  2. Re: echo card   Reply   Report abuse  
Picture of rudie dirkx rudie dirkx - 2010-10-29 07:32:54 - In reply to message 1 from Marek Miglinski
Hi Marek,

as you can see in the result of your print_r, $arrPlayer[0] is an Object, not an Array. To get elements from an object, you use -> instead of [], so you would get the 'short' property like this:

<?php
echo $arrPlayer[0]->short;
?>