By John Koster
accessible($value)
The accessible
helper method is used to determine whether the given $value
is array accessible. A value $value
is array accessible if the value is an array
or an instance of ArrayAccess
.
The following examples demonstrate the usage of the accessible
helper method. The results of the method call appear above the call as a comment:
1<?php
2
3// Create some test objects to work with.
4$array = [];
5$collection = collect([]);
6$model = factory('App\User')->make();
7$class = new stdClass;
8
9// true
10Arr::accessible($array);
11
12// true
13Arr::accessible($collection);
14
15// true
16Arr::accessible($model);
17
18// false
19Arr::accessible($class);
20
21// false
22Arr::accessible(null);
∎