You can encode an array thus:
$cars = [
'ALFA' => [
'title' => 'Alfa Romeo',
'models' => [ ... ]
],
'ACURA' => [
'title' => 'Acura',
'models' => [ ... ]
],
];
This can then be run through json_encode()
.
solved Generating JSON with PHP [closed]