Skip to content

Commit 00a4c0f

Browse files
[12.x] Add Arr::hasAll method to helpers (#10441)
* add `Arr::hasAll` method to helpers * Update helpers.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 0f91abc commit 00a4c0f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

helpers.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
5555
[Arr::from](#method-array-from)
5656
[Arr::get](#method-array-get)
5757
[Arr::has](#method-array-has)
58+
[Arr::hasAll](#method-array-hasall)
5859
[Arr::hasAny](#method-array-hasany)
5960
[Arr::integer](#method-array-integer)
6061
[Arr::isAssoc](#method-array-isassoc)
@@ -557,6 +558,21 @@ $contains = Arr::has($array, ['product.price', 'product.discount']);
557558
// false
558559
```
559560

561+
<a name="method-array-hasall"></a>
562+
#### `Arr::hasAll()` {.collection-method}
563+
564+
The `Arr::hasAll` method determines if all of the specified keys exist in the given array using "dot" notation:
565+
566+
```php
567+
use Illuminate\Support\Arr;
568+
569+
$array = ['name' => 'Taylor', 'language' => 'php'];
570+
571+
Arr::hasAll($array, ['name']); // true
572+
Arr::hasAll($array, ['name', 'language']); // true
573+
Arr::hasAll($array, ['name', 'ide']); // false
574+
```
575+
560576
<a name="method-array-hasany"></a>
561577
#### `Arr::hasAny()` {.collection-method}
562578

0 commit comments

Comments
 (0)