具有多维数组的Foreach-Laravel Blade模板

档案保管员

我有以下数组结果集,我试图遍历每个结果,然后将它们回显到页面上。我正在使用Laravel 5.2和刀片模板引擎

Collection {#240 ▼
  #items: array:3 [▼
    0 => array:2 [▼
      "name" => "desktop"
      "views" => "349"
    ]
    1 => array:2 [▼
      "name" => "mobile"
      "views" => "151"
    ]
    2 => array:2 [▼
      "name" => "tablet"
      "views" => "68"
    ]
  ]
}

这就是我到目前为止

@foreach($devices as $device)
    $key = 0; $key++; $key < 2;
    {{ $device[$key] }},
@endforeach
Mahfuzul Alam |
@foreach($devices as $device)
    {{ $device->name }}

    {{ $device->views}}
@endforeach

足够了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章