【发布时间】:2020-10-20 04:46:52
【问题描述】:
我得到了一个看起来像这样的数组
$arr = [
'body' => "",
'json' => [
'status' => '1',
'fields' => [
'title' => 'Product 1',
'category' => 'Category 1',
'description' => 'Test User 12',
],
'token' => 'egrgreGERGREglergjerjgiorj'
],
'status' => 200,
];
我想做的是显示所有数据。我遇到的问题是我收到此错误
htmlspecialchars() 期望参数 1 是字符串,给定数组
这是我的代码。
我的控制器
$arr = [
'body' => "",
'json' => [
'status' => '1',
'fields' => [
'title' => 'Product 1',
'category' => 'Category 1',
'description' => 'Test User 12',
],
'token' => 'egrgreGERGREglergjerjgiorj'
],
'status' => 200,
];
return view('test', ['array' => $arr2]);
我的刀
@if(isset($arr2))
@foreach($arr2 as $k => $v)
{{ $k }} - {{ $v }}
@endforeach
@endif
【问题讨论】:
-
请在此处发布您在代码中使用
htmlspecialchars函数的地方。 -
@NikuNjRathod: Blade 模板引擎在回显值时使用
htmlspecialchars()