PHP code example of vyuldashev / xml-to-array
1. Go to this page and download the library: Download vyuldashev/xml-to-array library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vyuldashev / xml-to-array example snippets
use Vyuldashev\XmlToArray\XmlToArray;
$xml = '<items>
<good_guy>
<name>Luke Skywalker</name>
<weapon>Lightsaber</weapon>
</good_guy>
<bad_guy>
<name>Sauron</name>
<weapon>Evil Eye</weapon>
</bad_guy>
</items>';
$result = XmlToArray::convert($xml);
array:1 [
"items" => array:2 [
"good_guy" => array:2 [
"name" => "Luke Skywalker"
"weapon" => "Lightsaber"
]
"bad_guy" => array:2 [
"name" => "Sauron"
"weapon" => "Evil Eye"
]
]
]