You can't do it with array_get
. If you take a look at the function (vendor/laravel/framework/src/Illuminate/Support/helpers.php:155):
function array_get($array, $key, $default = null)
{
return Arr::get($array, $key, $default);
}
Which calls the get function of the Arr
class (vendor/laravel/framework/src/Illuminate/Support/Arr.php:278):
public static function get($array, $key, $default = null)
{
if (! static::accessible($array)) {
return value($default);
}
if (is_null($key)) {
return $array;
}
if (static::exists($array, $key)) {
return $array[$key];
}
if (strpos($key, '.') === false) {
return $array[$key] ?? value($default);
}
foreach (explode('.', $key) as $segment) {
if (static::accessible($array) && static::exists($array, $segment)) {
$array = $array[$segment];
} else {
return value($default);
}
}
return $array;
}
If you take a look at the foreach loop which handles the .
, it does not support the structure your array has.