How to iterate over this array?

Arrives here this array:
array(5) {
[0]=>
 array(2) {
["id"]=>
 string(1) "1"
["cartridges"]=>
 string(33) "Cartridge HP 123 (F6V16AE)"
}
[1]=>
 array(2) {
["id"]=>
 string(1) "2"
["cartridges"]=>
 string(26) "HP Cartridge CF217A"
}
[2]=>
 array(2) {
["id"]=>
 string(1) "3"
["cartridges"]=>
 string(26) "HP Cartridge CF218X"
}
[3]=>
 array(2) {
["id"]=>
 string(1) "4"
["cartridges"]=>
 string(36) "Cartridge Canon Cartridge 703"
}
[4]=>
 array(2) {
["id"]=>
 string(1) "5"
["cartridges"]=>
 string(36) "Cartridge of Canon Cartridge 712"
}
}

Sorted it like so:
foreach ($select_printer as $item){
 foreach($item as $key => $value) {
 echo '<option id="' . $value . '"' . $value."</option>";
}
}

But for some reason I have 1 cycle takes only the first element of a nested array, but not both.
I like that for one cycle took 2 and item ["id"] and ["cartridges"]
I tried to use list($a, $b) but then nothing displays
April 4th 20 at 00:39
1 answer
April 4th 20 at 00:41
Solution
foreach ($select_printer as $arrayElement) {
 echo '<option id="', $arrayElement['id'], ">", $arrayElement["cartridges"], "</option>";
}


There is a foreach is sufficient.
Thank you very much!! - anika_Parker commented on April 4th 20 at 00:44

Find more questions by tags PHP