Stream context create not showing correct ouput?
<p>I am connecting up to an API and as a result it should loop and output 5 iterations of the results from the checks.</p>

<p><strong>The code</strong></p>

<pre><code>&lt;?php

      $i = 0;

$opts = array(
  'https'=&gt;array(
    'method'=&gt;"POST",
    'header'=&gt;"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

$fp = fopen('https://ssl.theapidomain.com.au/check.php?domain=testdomain&amp;suffixes=com.au', 'r', false, $context);

    while ($i &lt; 5) {
      fpassthru($fp);
      $out = explode('&lt;br&gt;', $fp);
      echo $out[0];
      echo "&lt;br&gt;";
      echo $out[1];
      echo "&lt;br&gt;";
      echo date('H:i:s');
      echo "&lt;br&gt;";
      $i++;
    }

fclose($fp);

?&gt;
</code></pre>

<p><strong>The output</strong></p>

<p>available: testdomain.com.au
not available:
whoisfailure: Resource id #2</p>

<p>16:58:57</p>

<p>Resource id #2</p>

<p>16:58:57</p>

<p>Resource id #2</p>

<p>16:58:57</p>

<p>Resource id #2</p>

<p>16:58:57</p>

<p>Resource id #2</p>

<p>16:58:57</p>

<p>It should be outputting this 5 times:</p>

<p>available: testdomain.com.au
not available:
16:58:57</p>

<p>It seems when I echo $out[0] and [2], it displays the resource id rather than the information inside (available / not available).</p>
