PHP array within a class

I want to do the following VB code in PHP

Public Class DeckOfCards
    Dim cardNumber(51) As Integer

    Sub New()
        For cntr = 0 To 51
            cardNumber(cntr) = cntr
        Next
    End Sub

    Public Function GetCardNumber(ByVal crdNmbr As Integer) As Integer
        Return Me.cardNumber(crdNmbr)
    End Function

End Class


How would I go about it?
acsakanyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nplibConnect With a Mentor Commented:
this should do it.


class DeckOfCards {
  public static $cardNumber = array();
 
  function __construct() {
      for ($cntr = 0; $cntr <= 51; $cntr++) {
           $cardNumber[] = $cntr;
      }
  }
 
  function GetCardNumber($crdNmbr) {
     return self::$my_static[$crdNmbr];
  }
}

Open in new window

0
 
Beverley PortlockCommented:
Looks like homework
0
 
acsakanyAuthor Commented:
Just what I needed. Thank you.
0
All Courses

From novice to tech pro — start learning today.