Hi,
I have a code snippet which stores the tags and value in an array (indexed). Please see below:
<foo>Test</foo>
$data['foo'] = 'Test';
But when I store the tag which has attributes as mentioned below, it does not accept.
<foo order='1'>Test</foo>
Array: $data['foo'] = array('_'=>'Test','order'=>'1'); //Referred from forums
But it sets the attributes and not actual data for the tag.
Please help me in this, how to do this.
Thanks & Regards,
Julias
How to convert XML tags with attributes to array
Moderator: General Moderators
-
juliasceasor
- Forum Newbie
- Posts: 1
- Joined: Mon Jan 02, 2017 4:57 am
Re: How to convert XML tags with attributes to array
Would help if you showed the code you were using.juliasceasor wrote:I have a code snippet which stores the tags and value in an array (indexed).
That said, have you looked at SimpleXML and/or xml_parse_into_struct?