April 11, 2018 —John Koster
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 signature of the accessible
method is:
1public static function accessible(2 $value3);
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 2// Create some test objects to work with. 3$array = []; 4$collection = collect([]); 5$model = factory('App\User')->make(); 6$class = new stdClass; 7 8// true 9Arr::accessible($array);10 11// true12Arr::accessible($collection);13 14// true15Arr::accessible($model);16 17// false18Arr::accessible($class);19 20// false21Arr::accessible(null);
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.