I have an array output. It should have a set of tuples within it. I create those tuples on the run from the for loop. (Simplified version of my code - the logic is the same, but $ind is calculated in a more complex way)
$output = Array();
$length = count($data);
for ($i = 0; $i < $length; $i++) {
$ind = $i - ($i % 2);
array_push($output[$ind], $data[$i]);
}
Here is the sample input ($data):
[10,2,123,4,34,6]
And a sample output ($output):
[[10,2],[123,4,],[34,6]]
But I get (not even empty arrays):
[,,] == [null,null,null]
$data[$i] is an integer. I tries to explicitly call intval() on it - still no luck. Also *array_push()* does not return anything after execution. No errors or warnings thrown..