0
尝试使用此,Laravel将数组传递给刀片
return View::make('products.tables')->with('json', $json);
但得到的数组到字符串转换错误。
JSON数组
$json = array (
"item1" => "no1",
"item2" => "no2",
"item3" => "no3",
);
尝试使用此,Laravel将数组传递给刀片
return View::make('products.tables')->with('json', $json);
但得到的数组到字符串转换错误。
JSON数组
$json = array (
"item1" => "no1",
"item2" => "no2",
"item3" => "no3",
);
这意味着,在你看来,你在呼唤数组项走错了路。
它应该是这样的:
$json->item1
或者:
@foreach($json as $item)
{{ $item }}
@endforeach
试试这个:
$json = array (
"item1" => "no1",
"item2" => "no2",
"item3" => "no3",
);
$data = array (
'json' => $json
);
return View::make('products.tables')->with($data)
,然后在您的视图:
@foreach($json as $item)
{{ $item }}
@endforeach
这应该工作。
该错误可能发生在别的地方。你可以请发表你的其他代码吗? – lukasgeiter
你能否提供'$ json'变量的结构? – sanis
你如何在你的视图中输出这个? – user3158900