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