November 20, 2016 —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// true10Arr::accessible($array);11 12// true13Arr::accessible($collection);14 15// true16Arr::accessible($model);17 18// false19Arr::accessible($class);20 21// false22Arr::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.