0
print_r($value->billTo);
OUTPUT
 SimpleXMLElement Object (  
     [firstName] => Joseph  
     [lastName] => Stalin  
     [address] => 12345 Test Lane  
     [city] => Navarre  
     [state] => FL  
     [zip] => 32561  
     [country] => USA  
     [phoneNumber] => 4025555555 )  
foreach($value->billTo as $classx => $valuex){
  $DOM_payments .= "\t\t  <p class='".$classx."'>".$valuex."</p>\n";
}

echo $DOM_payments;
OUTPUT
<p class='billTo'></p>

It should be printing:

<p class='firstname'>Joseph</p>  
...  
...  
<p class='phoneNumber'>4025555555</p>  

I am not sure what I am doing wrong to make it so I am not getting my expected results. Any help would be greatly appreciated :D

1 Answer 1

0

you have got to convert the SimpleXMLElement to an array to use it in a foreach

see here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your response. I changed the foreach loop to use (array)$value->billTo instead of just $value->billTo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.