devWhiz Posted August 17, 2011 Share Posted August 17, 2011 I have tried simplexml but I couldnt seem to get it.. the xml is like so <xml> <entry> <id>17</id> <name>brad</name> <age>18</age> </entry> <entry> <id>24</id> <name>clueless</name> <age>18</age> </entry> <entry> <id>22</id> <name>crazywhiteboy</name> <age>18</age> </entry> </xml> I need to get the information into an array where the ID is the attribute for the entry.. like $Info[17]['name'] so that would equal brad how can I do this? I have tried simplexml with a foreach loop $xml = simplexml_load_file("xml.xml"); foreach($xml->entry as $Info){ $ID = $Info->id; $Information[$ID]['Name'] = $Info->name; $Information[$ID]['Age'] = $Info->age; } print_r($Information); sleep(100000); That outputs a blank array.. what I can do? Link to comment https://forums.phpfreaks.com/topic/244977-put-this-xml-data-into-an-array-but-i-need-to-change-something/ Share on other sites More sharing options...
devWhiz Posted August 18, 2011 Author Share Posted August 18, 2011 anyone able to point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/244977-put-this-xml-data-into-an-array-but-i-need-to-change-something/#findComment-1258873 Share on other sites More sharing options...
darkfreaks Posted August 18, 2011 Share Posted August 18, 2011 http://www.bytemycode.com/snippets/snippet/445/ Link to comment https://forums.phpfreaks.com/topic/244977-put-this-xml-data-into-an-array-but-i-need-to-change-something/#findComment-1258875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.