Arr::has

Posted on November 16, 2016

The Arr::has function checks that a given item exists in an array using "dot" notation.

Example usage

$array = ['products' => ['desk' => ['price' => 100]]];

$hasDesk = Arr::has($array, 'products.desk');

// true

$array1 = [
    ['id' => 1, 'name' => 'John Doe'],
    ['id' => 2, 'name' => 'Jane Doe']
];

$result = Arr::has($array1, '2.name');

// false

Parameters

\ArrayAccess|array $array

string $key

Return Value

bool

0 Comments

Leave a Reply

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