php xml to array
php xml to array |
this is very simple codes to convert php xml to array..
create xml file: file.xml
<?xml version="1.0"?> <user_info> <title>Users Information</title> <totalRows>3</totalRows> <rows> <user> <name>ANJAN KUMAR</name> <email>Anjankumardhali@gmail.com</email> <education>Physics</education> </user> <user> <name>Palash Mondal</name> <email>Palsh@mail.com</email> <education>Computer Science</education> </user> <user> <name>Nikita Adikary</name> <email>Niki@nikita.com</email> <education>Software Engineering</education> </user> </rows> </user_info>
Create php file to access xml file: xml_to_array.php
<?php //xml file path $path = "file.xml"; //read entire file into string $xmlfile = file_get_contents($path); //convert xml string into an object $xml = simplexml_load_string($xmlfile); $json = json_encode($xml); //convert into associative array $xmlArr = json_decode($json, true); print_r($xmlArr); ?>
That's it friends how to convert xml to array using php..if you like this post please share with your friends..Thank You..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.