use Doctrine\Common\Collections\ArrayCollection; // Create a new ArrayCollection with some objects $collection = new ArrayCollection([ new Person('John', 'Doe'), new Person('Jane', 'Doe'), new Person('Bob', 'Smith') ]); // Get the object at index 1 $person = $collection->get(1); echo $person->getFullName(); // Outputs "Jane Doe"
use Doctrine\Common\Collections\ArrayCollection; // Create a new ArrayCollection with some objects $collection = new ArrayCollection([ new Person('John', 'Doe'), new Person('Jane', 'Doe'), new Person('Bob', 'Smith') ]); // Loop through the collection and describe each object foreach ($collection as $person) { echo $person->describe(); // Outputs "Name: John Doe, Email: john@doe" }Overall, the ArrayCollection is a useful class provided by the Doctrine Common library for working with collections of objects in PHP.