helper , 我可以获取 fname、lname 等的值..,但我正在努力获取 address1、city.. 的值,我的数组所在的位置,
Array
(
[id] => 172
[fname] => Someone
[lname] => Sombody
[gender] => Male
[phno] => 0123456789
[addresses] => Array
(
[0] => Array
(
[id] => 71
[user_id] => 172
[address1] => somewhere
[city] => some city
[state] => some state
[country] => India
)
[1] => Array
(
[id] => 72
[user_id] => 172
[address1] => someplace
[city] => specified city
[state] => specified state
[country] => India
)
)
)
最佳答案
如果你真的想以 Laravel 的方式做到这一点,你可以使用 collection
。
举个例子
$collection = collect(Your array);
$filtered = $collection->only(['addresses']);
$filtered->all();
//it will return the your desired collection
希望对你有帮助
关于mysql - 我如何从 laravel 中的数组中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49049838/