简体   繁体   中英

handling JSON and XML array

Basically, I'm working with 2 API's in which I want to integrate inside one file, one of the API returns a JSON Array. The other returns an XML.

Here's the idea in which I want to be able to do

$arr = (array)file_get_contents(JSON API);
$arr2 = (array)simplexml_load_file("XML API");

$details['Details']['1'] = $arr['Details']['0'];
$details['Details']['2'] = $arr2['Details']['0'];

foreach($details['Details'] as $detail) {
 //do what i want with the array
}

But how can I get the JSON API inside this Array ? I'm sorry if it's hard to understand what I'm asking but it's the best I can explain.

there is a way to convert the JSON to an XML Document ?

您可以使用array_merge()

 $details = array_merge($arr, $arr2);

There is a way for converting the JSON to an XML Document at the Link . It would be helpful to you to manipulate the data as required by you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM