I have the following array:
Array(
[0] => 0,0
[1] => 0,1
[2] => 0,2
[3] => 0,3
[4] => 1,0
[5] => 1,1
[6] => 1,2
[7] => 2,0
[8] => 2,1
[9] => 2,2
[10] => 2,3
)
And I would like to split it into the following structure:
Array(
[0] => Array (
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
[1] => Array (
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
[2] => Array (
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
[3] => Array (
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
i.e., in the “X,Y” value, X corresponds to the position of value “Y” in the new array. I can’t seem to get my head around the logic, its my first using ‘foreach’ in such a way.
Any help would be greatly appreciated pointing me in the right direction.
The input and output arrays in your example don’t quite match up, but I’m guessing you’re looking for this: