<?php
$fruits = [
'citrus'=>[
'fruit one'=>'orange', 'fruit two'=>'lime'
],
'melon'=>[
'fruit one'=>'honeydew', 'fruit two'=>'cantaloupe'
],
'berry'=>[
'fruit one'=>'raspberry', 'fruit two'=>'strawberry'
],
'apple'=>[
'fruit one'=>'granny smith', 'fruit two'=>'fuji'
],
];
foreach(array_slice($fruits,0,2) as $fruitGroup) echo $fruitGroup['fruit one']."\n";
echo "\n";
foreach(array_slice($fruits,2,2) as $fruitGroup) echo $fruitGroup['fruit one']."\n";
- Output for 5.6.0 - 5.6.24, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- orange
honeydew
raspberry
granny smith
preferences:
48.28 ms | 407 KiB | 5 Q