9
You might be interested in SPL's MultipleIterator
e.g.
// ArrayIterator is just an example, could be any Iterator.
$a1 = new ArrayIterator(array(1, 2, 3, 4, 5, 6));
$a2 = new ArrayIterator(array(11, 12, 13, 14, 15, 16));
$it = new MultipleIterator;
$it->attachIterator($a1);
$it->attachIterator($a2);
foreach($it as $e) {
echo $e[0], ' | ', $e[1], "\n";
}
prints
1 | 11
2 | 12
3 | 13
4 | 14
5 | 15
6 | 16
I don't understand what you're trying to do. If you want to reach them one after the other just use two loops:
foreach ($a as $b) { ... }
foreach ($c as $d => $e) { ... }
If you want all combinations from $a and $c:
foreach ($a as $b) {
foreach ($c as $d => $e) {
// do stuff
}
}
I guess you could do something like:
foreach (array_merge($a, $c) as $k => $v) {
...
}
but I wouldn't necessarily advise it.