Minwork Array
  • Minwork Array
  • Common methods
    • has
    • get → getNestedElement
    • set → setNestedElement
    • remove
    • clone
    • getKeysArray
  • Object oriented methods
    • General information
  • Traversing array
    • Finding
    • Iterating
  • Manipulating array
    • Mapping
    • Filtering
    • Grouping
    • Sorting
    • Computations
    • Flattening
  • Validating array
    • check
    • isEmpty
    • isNested
    • isArrayOfArrays
    • isAssoc
    • isUnique
    • isNumeric
    • hasKeys
  • Utility methods
    • pack
    • unpack
    • createMulti
    • forceArray
    • getDepth
    • random
    • shuffle
    • nth
    • getFirstKey
    • getLastKey
    • getFirstValue
    • getLastValue
Powered by GitBook
On this page

Was this helpful?

  1. Common methods

clone

Definition

Arr::clone(array $array): array

Description

Copy array and clone every object inside it

Examples

$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
PreviousremoveNextgetKeysArray

Last updated 5 years ago

Was this helpful?