use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection(); $collection->add('Element 1'); $collection->add('Element 2'); $collection->add('Element 3');
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection(['Element 1', 'Element 2', 'Element 3']); foreach ($collection as $element) { echo $element . "\n"; }
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection(['Element 1', 'Element 2', 'Element 3']); $collection->remove(1); // remove the element at index 1 foreach ($collection as $element) { echo $element . "\n"; }The Doctrine\Common\Collections\Collection belongs to the Doctrine Common package library, which provides a set of utility classes used by the various Doctrine packages.