The best place to find answers to general (and somewhat easy questions) such as this is to read up on PHP docs. Specifically in your case you can read more on objects. You can store stdObject and instantiated objects within an array. In fact, there is a process known as 'hydration' which populates the member variables of an object with values from a database row, then the object is stored in an array (possibly with other objects) and returned to the calling code for access.
-- Edit --
class Car
{
public $color;
public $type;
}
$myCar = new Car();
$myCar->color = 'red';
$myCar->type = 'sedan';
$yourCar = new Car();
$yourCar->color = 'blue';
$yourCar->type = 'suv';
$cars = array($myCar, $yourCar);
foreach ($cars as $car) {
echo 'This car is a ' . $car->color . ' ' . $car->type . "\n";
}
Yes, its possible to have array of objects in PHP.
class MyObject {
private $property;
public function __construct($property) {
$this->Property = $property;
}
}
$ListOfObjects[] = new myObject(1);
$ListOfObjects[] = new myObject(2);
$ListOfObjects[] = new myObject(3);
$ListOfObjects[] = new myObject(4);
print "<pre>";
print_r($ListOfObjects);
print "</pre>";
Although all the answers given are correct, in fact they do not completely answer the question which was about using the [] construct and more generally filling the array with objects.