Reputation: 19
This is the sample array
Array
(
[note] => Array
(
[to] => Array
(
[user] => Array
(
[name] => First User
)
[abc] => 123
[lmn] => 4582
)
[from] => Jani
[heading] => Reminder
[body] => Array
(
[abc] => 123
)
)
)
I have a string like "note > to > abc" and want value of "abc" under "to" array. So how can I get the value?
Upvotes: 1
Views: 600
Reputation: 4271
In laravel, there is a helper method named data_get()
for getting a specific key without throwing error if it doesn't exists.
It is documented here
You can use it like below:
data_get($arr, 'note.to.abc)
Upvotes: 5