-
-
Notifications
You must be signed in to change notification settings - Fork 0
Array Helper
Mattias edited this page Aug 1, 2021
·
1 revision
The data_get function retrieves a value from a nested array or object using "dot" notation.
data_get($target, $key, $default)
- target (array/object) (Required)
- key (string) (Required)
- default (string) (Optional)
$data = [
'name' => 'John Doe',
'age' => 30,
'kids' => [
[
'name' => [
'firstname' => 'Iroh',
'lastname' => 'Git',
],
'age' => 12,
],
[
'name' => [
'firstname' => 'Git',
'lastname' => 'hub',
],
'age' => 22,
],
],
];
$first_kid = arr()->data_get(
$data
'kids.0.name'
);