|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mgudelj Smarty n00b
Joined: 19 Sep 2014 Posts: 1
|
Posted: Fri Sep 19, 2014 8:15 am Post subject: php simplexml multilevel to arry |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Sep 20, 2014 12:04 pm Post subject: |
|
|
Simple way to convert a simplexml object to an array is
Code: | $array = json_decode(json_encode($xml), true);
|
|
|
Back to top |
|
|
|
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
|