I need to know how to store this data into one or two arrays with keys and export them into json format.
Here is the XML input, that I'm parsing:
<a id="12">
<n>Usa</n>
<a id="28">
<n>Maroko</n>
</a>
<a id="33">
<n>Finland</n>
</a>
<a id="41">
<n>Russia</n>
</a>
I haven't problem to parse this data, but how should I store this data into array with keys ("id", "country") and export into json with json_encode. I would like to get this output:
[
{
"id":"12",
"country":"Usa"
},
{
"id":"28",
"country":"Maroko"
},
{
"id":"33",
"country":"Finland"
},
{
"id":"41",
"country":"Russia"
}
]
I know, very simple, but I can't find the answer. Many thanks