Jump to content

put this xml data into an array but I need to change something..


devWhiz

Recommended Posts

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.