title: How to get array contents in PHP
body: <p>I am trying to echo a response (array) in PHP, but its not returning the desired value.</p>
  <p>Here is my code</p>
  <pre><code>&lt;?php
  $id = $_GET['id'];
  $array = file_get_contents('http://wen.com/api.php?id='.$id);
  echo $array[0]; // it returns A, while I need Friday here
  echo $array[1]; // it returns r, while I need Tuesday, 17 November here
  
  
  ?&gt;
  </code></pre>
  <p>the response from file_get_contents, is:</p>
  <pre><code>Array ( [0] =&gt; Friday [1] =&gt; Tuesday, 17 November [2] =&gt; Tuesday, 17 November [3] =&gt; Friday )
  
  </code></pre>
  <p>EDITED:</p>
  <p>The code of the api that I am using obove in file_get_contents, is :</p>
  <pre><code>$html =  file_get_contents(&quot;$url&quot;);
  
  
  
   $dom = new DomDocument();
              $dom-&gt;loadHTML($html);
              $dom_xpath = new DOMXpath($dom);
              $elements = $dom_xpath-&gt;query('//span[@class=&quot;nowrap&quot;]');
              foreach($elements as $data){
                 $array[] = $data-&gt;nodeValue;
              }
  
  print_r($array);
  
  </code></pre>