How To Create List of Class?
Posted: Sun Feb 22, 2009 12:30 am
I am wondering how I can create a list of one of my classes. As an example, I have a class called Product, and it has properties of ProductID, and ProductName. These values get pulled and populated from the database via accessors.
How can I create an object, say, $objProducts that contains a list of class Product. Then, I could loop through $objProducts looking at each individual Product object.
In VB.NET you can do this by: Dim objProducts As New List Of clsProduct. Then I can add instances of clsProduct to this list.
Can I use an ArrayList? Is there something better I can use? I just started using PHP today, but I wasn't able to find anything about this.
Thanks!
How can I create an object, say, $objProducts that contains a list of class Product. Then, I could loop through $objProducts looking at each individual Product object.
In VB.NET you can do this by: Dim objProducts As New List Of clsProduct. Then I can add instances of clsProduct to this list.
Can I use an ArrayList? Is there something better I can use? I just started using PHP today, but I wasn't able to find anything about this.
Thanks!