Convert XML to an array in PHP

20 minutes read

XML2Array is a class to convert XML file content to an associative array in PHP.
It returns an array which can be used for data insertion into database.

Its simply take string xml content as input and return array.
Its very user when we are handling with xml files getting from SOAP and curl request.

Class for converting xml to array file named as “xml2ArrayParser.class.php” copy paste below code to it. (Class Coded By : Shashank Patel)

After that make a new file named as “xml2Array.php” that contains below code:


Facebook Twitter LinkedIn Telegram Whatsapp

Related Posts:

What is PHP ? PHP stands for Hypertext Preprocessor and is a server-side language. PHP allows web developers to create dynamic content that interacts with databases. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becom...
Some times we need the visitor’s IP address for validation, security, spam prevention etc. Getting the Visitor’s IP address is very easy in PHP. We can get the Internet Protocol (IP) address of any visitor by using PHP. Get Clients IP address using PHP script ...
“How to Export MySQL data to Excel in PHP ?” This script will used to export data into .xls format from mysql database.You need to just copy this code and update database connection details. Below code will export mysql data into excel (.xls format) with ever...