I need to return a PHP array to Jquery, with the following format:
{
labels: [1, 2, 3],
series: [
[
{meta: 'description', value: 1},
],
]
}
How can I do this? I tried a few ways, and the one I came closest to is an index inserted in the path.
$return = array(
"labels" => [1,2,3],
"series" => [
array(
"meta" => ['description'],
"value" => [1],
),
],
);
You were close, you just have to make two corrections:
seriesvalueandmetavalues shouldn't be arraysYour array should look like this before encoding: