After asking a question yesterday, I've learned that I need to have an array in Php and use JSON to pass it to Javascript. I've got all that working up to a point, but I need to add one more dimension to my array and not sure how.
The current array is:
$result = array(
'NumberSelected' => $number,
'TargetPerc' => array (),
'KpiDescription' => array (),
'KpiName' => array (),
'ValuetoPrint' => array (),
'ValueNow' => array (),
'ValueCompare' => array (),
'Target' => array (),
'KpiUnits' => array ()
);
But I now need to enclose this in another dimension to sort these by group.
This is what I've tried:
$result = array(
$i => array(
'NumberSelected' => $number,
'TargetPerc' => array (),
'KpiDescription' => array (),
'KpiName' => array (),
'ValuetoPrint' => array (),
'ValueNow' => array (),
'ValueCompare' => array (),
'Target' => array (),
'KpiUnits' => array ()
)
);
With $i
defined as 0 two lines before that. But it doesn't seem to recognise the outermose array. Could be something to do with my collecting code which is result.KpiName[i]
currently (the JSON variable is passed to this javascript function as result
). And I've tried result.i[KpiName[i]]
with no success.
Any help would be appreciated.