1. Go to this page and download the library: Download vaclavvanik/dom-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/ */
vaclavvanik / dom-to-array example snippets
declare(strict_types=1);
use DOMDocument;
use VaclavVanik\DomToArray\DomToArray;
$doc = new DOMDocument();
$doc->loadXML('<root/>');
$result = DomToArray::toArray($doc);
// $result = ['root' => ''];
declare(strict_types=1);
use VaclavVanik\DomLoader\DomLoader;
use VaclavVanik\DomToArray\DomOptions;
use VaclavVanik\DomToArray\DomToArray;
// vaclavvanik/dom-loader turns a response string into a DOMDocument or a typed exception
$doc = DomLoader::loadString($apiResponseBody);
$domOptions = DomOptions::fromArray([
DomOptions::SKIP_ATTRIBUTES => true,
DomOptions::OMIT_ROOT_ELEMENT => true,
]);
$result = DomToArray::toArrayWithOptions($doc, $domOptions);