如何在laravel中循环收集对象?

时间:2017-12-30 04:33:05

标签: php laravel

我试图在laravel中预测循环。这是我的求职者的print_r结果。

Illuminate\Support\Collection Object ( 
    [items:protected] => Array ( 
        [0] => stdClass Object ( [myid] => 37 [max(call_back_date)] => 2018-12-12 ) 
        [1] => stdClass Object ( [myid] => 60 [max(call_back_date)] => 2017-12-12 ) 
        [2] => stdClass Object ( [myid] => 61 [max(call_back_date)] => 2017-11-30 ) 
        [3] => stdClass Object ( [myid] => 73 [max(call_back_date)] => 2017-11-29 ) 
        [4] => stdClass Object ( [myid] => 62 [max(call_back_date)] => 2017-11-28 ) 
        [5] => stdClass Object ( [myid] => 63 [max(call_back_date)] => 2017-11-22 ) 
        [6] => stdClass Object ( [myid] => 64 [max(call_back_date)] => 2017-11-15 ) 
        [7] => stdClass Object ( [myid] => 66 [max(call_back_date)] => 2017-11-15 ) 
        [8] => stdClass Object ( [myid] => 65 [max(call_back_date)] => 2017-11-10 ) 
        [9] => stdClass Object ( [myid] => 54 [max(call_back_date)] => 2017-10-24 ) 
        [10] => stdClass Object ( [myid] => 53 [max(call_back_date)] => 2017-09-30 ) 
        [11] => stdClass Object ( [myid] => 48 [max(call_back_date)] => 2017-09-20 ) 
        [12] => stdClass Object ( [myid] => 46 [max(call_back_date)] => 2017-08-26 ) 
        [13] => stdClass Object ( [myid] => 58 [max(call_back_date)] => 2017-12-12 ) 
        [14] => stdClass Object ( [myid] => 70 [max(call_back_date)] => 2017-11-29 ) 
        [15] => stdClass Object ( [myid] => 47 [max(call_back_date)] => 2017-08-20 ) 
        [16] => stdClass Object ( [myid] => 44 [max(call_back_date)] => 2017-08-18 ) 
        [17] => stdClass Object ( [myid] => 72 [max(call_back_date)] => 2018-02-17 ) 
        [18] => stdClass Object ( [myid] => 55 [max(call_back_date)] => 2000-12-12 ) 
        [19] => stdClass Object ( [myid] => 49 [max(call_back_date)] => ) 
        [20] => stdClass Object ( [myid] => 50 [max(call_back_date)] => ) 
        [21] => stdClass Object ( [myid] => 74 [max(call_back_date)] => ) 
        [22] => stdClass Object ( [myid] => 32 [max(call_back_date)] => ) 
    ) 
) 

我试过这个

foreach ($jobseekers as  $value) {
   echo $value->myid;
}

它只显示了我的第一项。像“37”,我期待很多项目。比如“37,60,61等...”。

1 个答案:

答案 0 :(得分:0)

我认为你需要做一个循环来迭代数据。

更新

尝试其中一个

foreach($jobseekers ->items as value){}

或者

foreach ($jobseekers as  $value) {
       foreach ($value as  $item) {}
}