use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection([1, 2, 3, 4, 5]);
// add an element to the end of the collection $collection->add(6); // remove an element from the collection $collection->remove(2); // sort the collection in descending order $collection->sortByDesc(function($number) { return $number; });In this example, we've added the number 6 to the end of the collection, removed the element at index 2 (which is 3) and sorted the collection in descending order. We can see that the ArrayCollection set provides us with a powerful and flexible object to work with. It makes it easy to manage collections of data and provides us with numerous methods to manipulate them. The ArrayCollection set is provided by the Doctrine\Common\Collections package library.