duannian7116 2016-02-13 06:39
浏览 503
已采纳

从php laravel 5中的数组中的数组中获取键值

I just want to get the value which is in array with in array. Following is my array.

I have a variable called $checklist.

$checklist = Checklist::where('equipment_id', Input::get('id'))->get()->toArray();

when I var_dump($checklist) it gives the following result.

array (size=2)
0 => 
array (size=10)
'id' => string 'a953fd4a509b41e0b12a1385aef7bca9' (length=32)
'checklist_template_id' => string '5d9ef7a83a4943c9a9580fd22d1dae2a' (length=32)
'ordre_id' => string '8b3392e34ff545b488d6623b2a27e7f5' (length=32)
'equipment_id' => string 'a797d64908024babb7e1eb4fc9167b78' (length=32)
'status' => string '' (length=0)
'image' => string '' (length=0)
'comment' => string '' (length=0)
'deleted_at' => null
'created_at' => string '2016-02-12 11:33:45' (length=19)
'updated_at' => string '2016-02-12 11:33:45' (length=19)
1 => 
array (size=10)
'id' => string 'ba5e4e822e5c44ba96132a9f196dc896' (length=32)
'checklist_template_id' => string '5d9ef7a83a4943c9a9580fd22d1dae2a' (length=32)
'ordre_id' => string '8b3392e34ff545b488d6623b2a27e7f5' (length=32)
'equipment_id' => string 'a797d64908024babb7e1eb4fc9167b78' (length=32)
'status' => string '' (length=0)
'image' => string '' (length=0)
'comment' => string '' (length=0)
'deleted_at' => null
'created_at' => string '2016-02-12 10:16:19' (length=19)
'updated_at' => string '2016-02-12 10:16:19' (length=19)

All I want is, get "checklist_template_id" alone... how can I get it? can anyone help me with it???

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • douxi1968 2016-02-13 07:12
    关注

    You can achieve this by looping your array as below

    $result = array();
    foreach($checklist as $key=> $val)
    {
      $result[] = $val['checklist_template_id'];
    }
    
    print_r($result);
    

    this should help you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?