Collection::toArray PHP Method

toArray() public method

Converts the current object into an array
public toArray ( $callback = null ) : array
return array
    public function toArray($callback = null)
    {
        if (is_null($callback)) {
            return $this->data;
        }
        return array_map($callback, $this->data);
    }

Usage Example

 public function testMap()
 {
     $this->collection->map(function ($item) {
         return sprintf('%s %s', $item['first_name'], $item['last_name']);
     });
     $this->assertEquals(['john smith', 'kara trace', 'phil mcKay', 'rose smith'], $this->collection->toArray());
 }
All Usage Examples Of Collection::toArray