Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

php simplexml multilevel to arry

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mgudelj
Smarty n00b


Joined: 19 Sep 2014
Posts: 1

PostPosted: Fri Sep 19, 2014 8:15 am    Post subject: php simplexml multilevel to arry Reply with quote

Hi,

What type of an array would I need to loop trough data as bellow. I have html template that is using below and would need to assign data to it.

{foreach from=$daily_details.day item=line name=itemlist}
$line.room_desc}
{/foreach}


my xml looks like one below


<smarty>
<GUEST_EMAIL>test@test.com</GUEST_EMAIL>
<daily_details>
<day>
<ROOM_DESC>test2</ROOM_DESC>
</day>
<day>
<ROOM_DESC>test3</ROOM_DESC>
</day>
<day>
<ROOM_DESC>test4</ROOM_DESC>
</day>
<day>
<ROOM_DESC>test5</ROOM_DESC>
</day>
</daily_details>
</smarty>


thank you for your help!
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Sep 20, 2014 12:04 pm    Post subject: Reply with quote

Simple way to convert a simplexml object to an array is

Code:
$array = json_decode(json_encode($xml), true);
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP