【发布时间】:2021-05-05 12:41:28
【问题描述】:
我将 json 存储在我的数据库中,并使用我的模型以解码格式检索它。 我将值传递给刀片并尝试在那里显示来自 json 的值。
我dd($properties) 得到这个:
array:1 [
"like" => 10
]
这有效:{{dd($properties["like"])}} 得到正确的整数值 10
但是当我执行{{$properties["like"]}} 时,它会返回"Cannot access offset of type string on string"。
但是$properties 不是字符串,因为当我{{$properties}} 时,它给出了"htmlspecialchars(): Argument #1 ($string) must be of type string, array given" 。 {{gettype($properties)}} 给了array。
【问题讨论】:
-
我对这个问题没有经验,但可能是
ArrayObject,尝试通过对象表示法$properties->like访问它,或尝试$properties{"like"}
标签: laravel laravel-blade