Perad Posted May 11, 2010 Share Posted May 11, 2010 I have the following bit of XML. <contactform> <label1 check="1" textarea="0">Name</label1> <label2 check="1" textarea="0">Address</label2> <label3 check="1" textarea="0">Email</label3> <label4 check="0" textarea="0">Phone</label4> <label5 check="0" textarea="0">Cell</label5> <label6 check="0" textarea="0">Comments</label6> </contactform> I need to get back the following. Label Name = Name Textarea = 0 Field Name = label1 The problem I have is getting the fieldname. How do I retrieve this? <?php foreach($contactform->children() as $label): ?> <label><?php echo $label; ?></label> <?php if ($label['textarea'] == 1): ?> <textarea name=""></textarea> <?php else: ?> <input type="text" name="" /> <?php endif; ?> <?php endforeach; ?> Link to comment https://forums.phpfreaks.com/topic/201339-simplexml-traversing/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.