0

したがって、基本的には foreach でいくつかの変数を表示したいのですが、サブメニューがあるため、ネストされたループで行う必要があります。

これはリストです:

<whmcsapi>
 <action>getclientsdomains</action>
 <clientid>123</clientid>
 <totalresults>2</totalresults>
 <startnumber>0</startnumber>
 <numreturned>2</numreturned>
 <domains>
 <domain>
  <id>1</id>
  <userid>123</userid>
  <orderid>1</orderid>
  <regtype>Register</regtype>
  <domainname>whmcsdomain.com</domainname>
  <registrar>enom</registrar>
  <regperiod>1</regperiod>
  <firstpaymentamount>8.95</firstpaymentamount>
  <recurringamount>8.95</recurringamount>
  <paymentmethod>paypal</paymentmethod>
  <paymentmethodname>Credit Card or Debit Card</paymentmethodname>
  <regdate>2011-01-01</regdate>
  <expirydate>2012-01-01</expirydate>
  <nextduedate>2012-01-01</nextduedate>
  <status>Active</status>
  <subscriptionid></subscriptionid>
  <dnsmanagement></dnsmanagement>
  <emailforwarding></emailforwarding>
  <idprotection></idprotection>
  <donotrenew></donotrenew>
  <notes></notes>
 </domain>
 ...
 </domains>
</whmcsapi>

最初のカテゴリ 2 番目のカテゴリです。

これは私がこれまでに達成したことですが、結果はありません:

    $command = 'getclientsdomains';
 $values = array('clientid' => $_SESSION['uid']);

 # Call API
 $results = localAPI($command,$values);

    foreach ($results as $id => $result) {

            echo $id . " " . $result ."<br />";

            foreach ($result as $domains) {

            echo $domains;

            foreach($domains as $key => $value) {

            echo $key . $value;

            }

            }

        }

これは出力です:

result success
clientid 1
domainid 
totalresults 1
startnumber 0
numreturned 1
domains Array
Array

前もって感謝します。

4

1 に答える 1

0

再帰関数を使用してデータをループする

function print_list($node) {
    foreach($node as $key => $value) {
         if(is_array($value)) 
             print_list($value);
         else
             echo "$key: $value\n";
    }
}
于 2012-03-08T23:29:45.650 に答える