Laravel data_get helper has different behavior for array and object
$array = ['key' => null];
echo data_get($array, 'key', 'default') // Result was default
$array = (object) $array;
echo data_get($array, 'key', 'default') // Result was null
Is there any specific reason it was done like this or arrays and objects?
Laravel doc ref
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-data_get-helper-has-different-behavior-for-array-and-object/
via Lzo Media
No comments:
Post a Comment