title: nested foreach combine php
body: <p>I keep geting wrong output as always get last amount for each wallet, anyone can help? thanks a lot.</p>
  
  <pre><code>foreach ( $xml-&gt;NewDataSet-&gt;WalletData as $PGW) {
      printf("%s\t%s\n", $PGW-&gt;walletID, $PGW-&gt;Walletamount);
  }
  </code></pre>
  
  <p>this foreach output is:</p>
  
  <pre><code>walletID    Walletamount
  1           100
  4           40
  </code></pre>
  
  <p>second foreach as blow:</p>
  
  <pre><code>foreach ( $xml2-&gt;NewDataSet-&gt;Provider as $provide) {
      if ($provide-&gt;WalletType == 'Black Wallet') {
          printf("%s\t%s\t%s\n", " ", $provide-&gt;WalletID, $provide-&gt;WalletName));
      }   
  }
  </code></pre>
  
  <p>output is:</p>
  
  <pre><code>amount   WalletID  WalletName  
           1         A
           2         B
           3         C
           4         D
           5         E
           6         F
  </code></pre>
  
  <p>how do i combine two foreach and output like this.</p>
  
  <pre><code>amount   walletname
  100.0    A
    0.0    B
    0.0    C
   40.0    D
    0.0    E
    0.0    F
  </code></pre>