I am using json_encode
to convert PHP arrays to json and it seems to work fine except for one thing.
If I have a multi-dimensional array like this:
$person = array(
'name' => 'John Smith',
'age' => 36,
'siblings' => array(
'male' => array('John Doe','Mark'),
'female' => array('Jane Doe','Jane Smith')
)
);
I want it to put brackets around siblings
but it only does it around male
and female
, i.e:
{
"name":"John Smith",
"age":36,
"siblings":{
"male":[
"John Doe",
"Mark"
],
"female":[
"Jane Doe",
"Jane Smith"
]
}
}
And I want "siblings":[{ ... }]
Is this possible?