【发布时间】:2018-10-08 20:09:54
【问题描述】:
所以我有多个输入以 json 格式保存到数据库中的一列中,并在检索时将该 json 转换为数组以输出正确的数据。
<input type="text" name="waypoints" class="form-control" autocomplete="on" value="{{ json_decode($myroute->waypoints, true)[0] }}">
上面的代码是输入中显示的数组中的第一项,所以如果我在哪里列出
{{ json_decode($myroute->waypoints, true)[0] }}
{{ json_decode($myroute->waypoints, true)[1] }}
{{ json_decode($myroute->waypoints, true)[2] }}
它会正确输出数组。但是,我如何计算出数组中有多少并且只显示正确数量的输入字段? (最多 10 个)
我尝试在输入字段周围使用@foreach ($myroutes as $myroute) 和@endforeach,但收到一条错误消息。
提前致谢!
【问题讨论】:
标签: arrays json database laravel laravel-5