Arr::divide

Posted on November 14, 2016

The Arr::divide function returns two arrays, one containing the keys, and the other containing the values of the original array:

Example usage

list($keys, $values) = Arr::divide(['name' => 'Desk']);

// $keys: ['name']
// $values: ['Desk']

$array = Arr::divide([1,2,3]);

// [
//     [0,1,2],
//     [1,2,3],
// ]

$array = Arr::divide(['id' => 1, 'name' => 'John Doe']);

// [
//     ['id', 'name'],
//     [1, 'John Doe'],
// ]

$array = Arr::divide([
    ['id' => 1, 'name' => 'John Doe'],
    ['id' => 2, 'name' => 'Jane Doe'],
]);

// [
//     [0,1],
//     [
//         ['id' => 1, 'name' => 'John Doe'],
//         ['id' => 2, 'name' => 'Jane Doe'],
//     ],
// ]

Parameters

array $array

Return Value

Array

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *