title: PHP For Loop - No Output After Loop
body: <p>I have a foreach loop, it's working fine - but for some reason anything out of the loop after it happens doesnt output. For example the echo $cpaTotal; doesn't display anything. </p>
  
  <p>For loop prints out perfect</p>
  
  <p>Where am I going wrong?</p>
  
  <pre><code>    $key = '84abf';
      $from = '2016/7/1';
      $to = '2016/9/17';
      $url = '/api/affreporting.asp?key='.$key.'&amp;reportname=QuickSummaryReportDetailed&amp;reportformat=xml&amp;reportmerchantid=0&amp;reportstartdate='.$from.'&amp;reportenddate='.$to;
      $clean_xml = str_ireplace(['SOAP-ENV:', 'SOAP:'], '', file_get_contents($url));
      $xml = simplexml_load_string($clean_xml);
      $obj = json_decode(json_encode($xml));
  
      $cpaTotal = 'test';
  
      foreach($obj-&gt;Body-&gt;reportresponse-&gt;row as $row)
      {
  
          $CPACommission = $row-&gt;CPACommission;
          $merchant = $row-&gt;merchantname;
          $Product1NetRevenue = $row-&gt;Product1NetRevenue;
  
          echo "Merchant: ".$merchant. " | ";
          echo "CPA Commission: ".$CPACommission." | ";
          echo "Net Revenue: ".$Product1NetRevenue."&lt;/br&gt;";
          echo "&lt;hr&gt;";
  
      }
      echo $cpaTotal;
  </code></pre>
  
  <p>Output (html)</p>
  
  <pre><code>Merchant: &lt;strong&gt;mFortune&lt;/strong&gt; | CPA Commission: &lt;strong&gt; &amp;pound;2270&lt;/strong&gt; | Downloads: &lt;strong&gt;34&lt;/strong&gt; | Net Revenue: &lt;strong&gt;&amp;pound;-161.4&lt;/strong&gt;&lt;br&gt;Merchant: &lt;strong&gt;PocketWin&lt;/strong&gt; | CPA Commission: &lt;strong&gt; &amp;pound;1330&lt;/strong&gt; | Downloads: &lt;strong&gt;22&lt;/strong&gt; | Net Revenue: &lt;strong&gt;&amp;pound;-134.77&lt;/strong&gt;&lt;br&gt;Merchant: &lt;strong&gt;Mr Spin&lt;/strong&gt; | CPA Commission: &lt;strong&gt; &amp;pound;680&lt;/strong&gt; | Downloads: &lt;strong&gt;31&lt;/strong&gt; | Net Revenue: &lt;strong&gt;&amp;pound;13.22&lt;/strong&gt;&lt;br&gt;
  </code></pre>