[英]how can I print user_Id from this array format?
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[user_id] => 3
)
)
)
I am using Laravel 8. I want to fetch single data and use it.我正在使用 Laravel 8。我想获取单个数据并使用它。
Please don't use print_r
to dump your records.请不要使用print_r
转储您的记录。 kindly use dd()
or dump()
.请使用dd()
或dump()
。 So you have a clear idea about collections.所以你对集合有一个清晰的概念。 So as of now, you fetch as所以到目前为止,你取为
$yourCollection->first()->user_id
if you have multiple models you can use loops.如果您有多个模型,则可以使用循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.