score:3

first of all, i like the idea of cms controllable highcharts! it's something i've done before too.

rather than have users enter all data points for a particular city (12 points: one for each month), i thought it'd be more intuitive to have users enter the data points for each month (4 points: one for each city).

personally, i think that's a bit counter intuitive. if you add another city, then a new value box pops up in 12 different places. whereas you could have a nice ajax process or something at the end of the input screen which allows the wordpress cms user to add another city dynamically, and entering the 12 new values in one place.

anyway, i don't know your website so your way could be more intuitive. for your specific problem, you can think of your array of arrays as a matrix - you just need to make them officially an array of arrays rather than lots of single arrays.

then you can use array_map to solve your problem:

$matrix = [
    [49.9, 83.6, 48.9, 42.4],
    [71.5, 78.8, 38.8, 33.2],
    [106.4, 98.5, 39.3, 34.5],
    [129.2, 93.4, 41.4, 39.7]
];

array_unshift($matrix, null);
$matrix = call_user_func_array('array_map', $matrix);

this guy provides a really good explanation of this above php process (better than i could!).


Related Query

More Query from same tag