XML String convert into array in php -
XML String convert into array in php -
i convert xml string array in php. generate bookstore array within 1 book array , nested array index 0,1,2. need same name (book) array bookstore. how generate type of array. xml string is....
$string = "<?xml version="1.0"?> <bookstore> <book> <name>php</name> <author>w3school</author> <price>200</price> </book> <book> <name>c#.net</name> <author>microsoft</author> <price>250</price> </book> <book> <name>asp.net</name> <author>microsoft</author> <price>350</price> </book> </bookstore>"; $value = simplexml_load_string($string); print_r($value);
in above code, run , output display in book array in 0,1,2 index.
simplexmlelement object ( [book] => array ( [0] => simplexmlelement object ( [name] => php [author] => w3school [price] => 200 ) [1] => simplexmlelement object ( [name] => c#.net [author] => microsoft [price] => 250 ) [2] => simplexmlelement object ( [name] => asp.net [author] => microsoft [price] => 350 ) ) )
but need 1 array name bookstore , nested array multiple book array replace of [0],[1],[2].
php
Comments
Post a Comment