use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection([ "apple", "banana", "cherry" ]); $array = $collection->toArray(); print_r($array);
Array ( [0] => apple [1] => banana [2] => cherry )
use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection([ ["name" => "John", "age" => 25], ["name" => "Jane", "age" => 30] ]); $array = $collection->toArray(); print_r($array);
Array ( [0] => Array ( [name] => John [age] => 25 ) [1] => Array ( [name] => Jane [age] => 30 ) )In both examples, we are using the `toArray()` method to convert an ArrayCollection into a regular PHP array. The PHP Doctrine Common Collections library is the package/library that provides the ArrayCollection class and the `toArray()` method.