Menu
Hello forums!!
Suppose we had the following classes:
[code=php]class A{
var $obj_array = array();
function setObject($classB_obj){
$this->obj_array[] = $classB_obj
}
}
class B{
var $id;
var $name;
function B($id, $name){
// necessary initialisation
}
}
Case:
I would like to set objects as:
[code=php]$objA->setObject(new B(1, “x”));
$objA->setObject(new B(2, “y”));
My Question:
How to make the property $obj_array to hold the class objects of B with unique id.
Thanks in advance for the kind help.