/** * Get a flattened array of the items in the collection. * * @return static */ public function flatten() { return new static(Arr::flatten($this->items)); }
public function testFlatten() { $array = ['name' => 'Joe', 'languages' => ['PHP', 'Ruby']]; $array = Arr::flatten($array); $this->assertEquals(['Joe', 'PHP', 'Ruby'], $array); }