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 upload a file from one server to another server using PHP cURL POST method. How to send files using PHP and cURL The cURL functions in PHP can be used to make HTTP requests to remote servers. The curl_setopt  method allows us a wide range of options to ...