Php / laravel刀片多维数组 [英] Php/laravel blade multidimensional array

查看:186
本文介绍了Php / laravel刀片多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的数组,我想用laravel刀片作为HTML表格获得它



I have the below arrays and I want to get it in laravel blade as HTML table

$chest = json_decode(Session::get('chest'),TRUE);







array:2 [▼
  "chest" => array:2 [▼
    "Chest Press" => array:1 [▼
      0 => "1"
    ]
    "Flys" => array:2 [▼
      0 => "3"
      1 => "4"
    ]
  ]
  "hints" => array:2 [▼
    "Chest Press" => array:1 [▼
      0 => "test1"
    ]
    "Flys" => array:1 [▼
      0 => "test2"
    ]
  ]
]





我尝试以下但我没有得到正确的HTML表,它正确的前两列但第三列不是,任何想法如何打印它在HTML桌面上



我尝试过:





I try the below but I dont get right HTML table, its correct the first two columns but the third columnt is not, any ideas how to print it on HTML table

What I have tried:

<table class="table table-striped table-hover table-reflow">
           <thead>
               <tr>
                 <th>Exercises</th>
                 <th>Days</th>
                 <th>Hints</th>


               </tr>
           </thead>
       <tbody>

       @foreach($chests['chest'] as $chest => $exc)
           <tr>
               <td>{{$chest}}</td>
               @foreach($exc as $key => $value)
                   <td>
                        {{$value}},
                   </td>
               @endforeach

       @endforeach

       @foreach($chests['hints'] as $hint => $hin)


               @foreach($hin as $key => $value)
                   <td>
                        {{$value}}
                   </td>

               @endforeach

             </tr>
       @endforeach

         </tbody>

推荐答案

chest = json_decode(Session :: get(' chest'),TRUE);
chest = json_decode(Session::get('chest'),TRUE);







array:2 [▼
  "chest" => array:2 [▼
    "Chest Press" => array:1 [▼
      0 => "1"
    ]
    "Flys" => array:2 [▼
      0 => "3"
      1 => "4"
    ]
  ]
  "hints" => array:2 [▼
    "Chest Press" => array:1 [▼
      0 => "test1"
    ]
    "Flys" => array:1 [▼
      0 => "test2"
    ]
  ]
]





我尝试以下但我没有得到正确的HTML表,它正确的前两列但第三列不是,任何想法如何打印它在HTML桌面上



我尝试过:





I try the below but I dont get right HTML table, its correct the first two columns but the third columnt is not, any ideas how to print it on HTML table

What I have tried:

<table class="table table-striped table-hover table-reflow">
           <thead>
               <tr>
                 <th>Exercises</th>
                 <th>Days</th>
                 <th>Hints</th>


               </tr>
           </thead>
       <tbody>

       @foreach(


chests ['chest '] as
chests['chest'] as


chest =>
chest =>


这篇关于Php / laravel刀片多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆