I have the following data which has gender and age category specific results of a race. The data is returned as an associative array.
In most categories I have three results, but in certain categories there might only be 1 or 2 results.
M50,1,9197,V50,M
M50,2,8253,V50,M
M50,3,18282,V50,M
W50,1,19961,V50,W
W50,2,7051,V50,W
W50,3,2480,V50,W
M55,1,7876,V55,M
M55,2,7640,V55,M
M55,3,19945,V55,M
W55,1,9029,V55,W
W55,2,6161,V55,W
W55,3,1172,V55,W
M60,1,7768,V60,M
M60,2,7112,V60,M
M60,3,7924,V60,M
W60,1,8747,V60,W
M65,1,7211,V65,M
M65,2,5234,V65,M
W65,1,8732,V65,W
M70,1,2952,V70,M
M70,1,2953,V70,W
M80,1,7953,V80,W
I want to transpose the array, so that each category is displayed as a single row, with a max of 6 results per row but any missing rows are filled with a blank.
M50 M1, M50 M2, M50 M3, M50 W1, M50 W2, M50 M3
M55 M1, M55 M2, M55 M3, M55 W1, M55 W2, M55 M3
M60 M1, M60 M2, M60 M3, M60 W1, x , x
M65 M1, M65 M2, x , M65 W1, x , x
M70 M1, x , x , M70 W1, x , x
x , x , x , M80 W1, x , x
Is there any recommendation on how i can achieve this in an efficent manner?