Arr::except

Posted on November 16, 2016

The Arr::except function removes the given key / value pairs from the array:

Example usage

$array = Arr::except(
    ['name' => 'Desk', 'price' => 100],
    ['price']
);

// ['name' => 'Desk']

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

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

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

// []

Parameters

array $array

array|string $keys

Return Value

Array

0 Comments

Leave a Reply

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