Convert XML to a PHP Array
Generate a PHP array literal from XML — perfect for config files and caches. Attributes, text and nested elements map to array keys.
Input
Output
About Convert XML to a PHP Array
Convert XML to a PHP Array produces a clean PHP array literal you can paste straight into PHP code. Elements become nested arrays, repeated elements become indexed arrays, attributes are stored under a configurable key and text under another.
Features
How to Use
Examples
The sample becomes $data = array('catalog' => array('product' => array(0 => array('@id' => 'p1', …))));
Benefits
Frequently Asked Questions
Is my XML sent to a server?
No. Everything runs locally in your browser. Your data is never uploaded, stored or logged.
Can I download the result?
Yes — use the Download button below the output area, or Print / Save PDF for a printable copy.