<?php
$myArrays = array(
array(1, 2, 3, 4),
array(5, 6, 7, 8),
array(9, 10, 11, 12),
array(13, 14, 15, 16)
);
foreach ($myArrays as $index => $myArray) {
if (($index % 2) != 0) {
echo implode("\n", array_reverse(array_column($myArrays, $index))) . "\n";
} else {
echo implode("\n", array_column($myArrays, $index)) . "\n";
}
}
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- 1
5
9
13
14
10
6
2
3
7
11
15
16
12
8
4
preferences:
102.75 ms | 404 KiB | 216 Q