> For the complete documentation index, see [llms.txt](https://minwork.gitbook.io/array/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://minwork.gitbook.io/array/common-methods/clone.md).

# clone

#### Definition

```php
Arr::clone(array $array): array
```

#### Description

Copy array and clone every object inside it

#### Examples

```php
$object = new class() {
    public $counter = 1;

    function __clone()
    {
        $this->counter = 2;
    }
};

$array = [
    'foo',
    'bar',
    $object,
    'test',
    'nested' => [
        'object' => $object
    ]
];

$cloned = Arr::clone($array);

$cloned[0] -> 'foo'
$cloned[2]->counter -> 2
$cloned['nested']['object']->counter -> 2
```
