2017-12-18 133 views
0
$rounds = $season->championsLeague->rounds->where('stage', 'Olympic')->take(2); 
    $indexes = []; 
    foreach ($rounds as $index => $round) { 
     $indexes[] = $index; 
    } 

    echo '<pre>';print_r($indexes);echo '<pre>'; 

我接收在索引:数组 ( [0] => 6 [1] => 7 )指数的foreach开始不与0

它是如何可能? 为什么不阵列 ( [0] => 0 [1] => 1 )

回答

0

切片,块,和反向现在方法在收集保存密钥。如果您不希望这些方法保留键,请使用Collection实例上的values方法。这是从laravel文档。我认为采取方法也是如此。