title: Nested Foreach Loops (PHP)
body: <p>So basically what i want is to display some some variables with foreach, but it need to be done with nested loops as it has submenus.</p>
  
  <p>This is the list:</p>
  
  <pre><code>&lt;whmcsapi&gt;
   &lt;action&gt;getclientsdomains&lt;/action&gt;
   &lt;clientid&gt;123&lt;/clientid&gt;
   &lt;totalresults&gt;2&lt;/totalresults&gt;
   &lt;startnumber&gt;0&lt;/startnumber&gt;
   &lt;numreturned&gt;2&lt;/numreturned&gt;
   &lt;domains&gt;
   &lt;domain&gt;
    &lt;id&gt;1&lt;/id&gt;
    &lt;userid&gt;123&lt;/userid&gt;
    &lt;orderid&gt;1&lt;/orderid&gt;
    &lt;regtype&gt;Register&lt;/regtype&gt;
    &lt;domainname&gt;whmcsdomain.com&lt;/domainname&gt;
    &lt;registrar&gt;enom&lt;/registrar&gt;
    &lt;regperiod&gt;1&lt;/regperiod&gt;
    &lt;firstpaymentamount&gt;8.95&lt;/firstpaymentamount&gt;
    &lt;recurringamount&gt;8.95&lt;/recurringamount&gt;
    &lt;paymentmethod&gt;paypal&lt;/paymentmethod&gt;
    &lt;paymentmethodname&gt;Credit Card or Debit Card&lt;/paymentmethodname&gt;
    &lt;regdate&gt;2011-01-01&lt;/regdate&gt;
    &lt;expirydate&gt;2012-01-01&lt;/expirydate&gt;
    &lt;nextduedate&gt;2012-01-01&lt;/nextduedate&gt;
    &lt;status&gt;Active&lt;/status&gt;
    &lt;subscriptionid&gt;&lt;/subscriptionid&gt;
    &lt;dnsmanagement&gt;&lt;/dnsmanagement&gt;
    &lt;emailforwarding&gt;&lt;/emailforwarding&gt;
    &lt;idprotection&gt;&lt;/idprotection&gt;
    &lt;donotrenew&gt;&lt;/donotrenew&gt;
    &lt;notes&gt;&lt;/notes&gt;
   &lt;/domain&gt;
   ...
   &lt;/domains&gt;
  &lt;/whmcsapi&gt;
  </code></pre>
  
  <p> is the first category
    the second one.</p>
  
  <p>This is what i have achieved so far but without results:</p>
  
  <pre><code>    $command = 'getclientsdomains';
   $values = array('clientid' =&gt; $_SESSION['uid']);
  
   # Call API
   $results = localAPI($command,$values);
  
      foreach ($results as $id =&gt; $result) {
  
              echo $id . " " . $result ."&lt;br /&gt;";
  
              foreach ($result as $domains) {
  
              echo $domains;
  
              foreach($domains as $key =&gt; $value) {
  
              echo $key . $value;
  
              }
  
              }
  
          }
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>result success
  clientid 1
  domainid 
  totalresults 1
  startnumber 0
  numreturned 1
  domains Array
  Array
  </code></pre>
  
  <p>Thanks in advance.</p>