I need to restructure some array data then pass it as a json string to generate a Google line chart.
In the result array, I need to create rows of three elements.
- the original element keys which are shared among all rows.
- the values from the first row.
- the values from the second row.
Input array:
[
1 => [
1 => 'c1',
2 => 'c1',
3 => 'c1',
4 => 'c1',
5 => 'c1'
],
10 => [
1 => 'c2',
2 => 'c2',
3 => 'c2',
4 => 'c2',
5 => 'c2'
]
]
Expected result is:
[[1,"c1","c2"],[2,"c1","c2"],[3,"c1","c2"],[4,"c1","c2"],[5,"c1","c2"]]