title: what's wrong in this html dom php code?
body: <p>I'm trying to do a code that will print the contents of all the elements with <code>itemprop="price"</code> from some link but it don't work, I can't figure out why, this is the code:</p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  ini_set('display_errors', 0);
  $doc      = new DOMDocument();
  $allscan  = array(
      'http://www.mobile54.co.il/30786',
      'http://www.mobile54.co.il/35873',
      'http://www.mobile54.co.il/34722'
  );
  $alllinks = array();
  $html     = file_get_contents($allscan[0]);
  $doc-&gt;loadHTML($html);
  $href = $doc-&gt;getElementsByTagName('a');
  for ($j = 0; $j &lt; count($allscan); $j++) {
      $html = file_get_contents($allscan[$j]);
      $doc-&gt;loadHTML($html);
      $href = $doc-&gt;getElementsByTagName('a');
      for ($i = 0; $i &lt; $href-&gt;length; $i++) {
          $link = $href-&gt;item($i)-&gt;getAttribute("href");
          $lin  = preg_replace('/\s+/', '', 'http://www.mobile54.co.il' . $link . "&lt;br /&gt;");
          if (strpos($link, 'items/') &amp;&amp; !strpos($link, '#techDetailsAName')) {
              if (!in_array($lin, $alllinks)) {
                  $alllinks[] = $lin;
              }
          }
      }
  }
  
  for ($i = 0; $i &lt; count($alllinks); $i++) {
      echo $alllinks[$i];
  }
  for ($i = 0; $i &lt; count($alllinks); $i++) {
      $lin  = "$alllinks[$i]";
      $html = file_get_contents($lin);
      $doc-&gt;loadHTML('&lt;?xml encoding="UTF-8"?&gt;' . $html);
      $span = $doc-&gt;getElementsByTagName('span');
      for ($j = 0; $j &lt; $span-&gt;length; $j++) {
          $attr = $span-&gt;item($j)-&gt;getAttribute('itemprop');
          if ($attr == "price") {
              echo $span-&gt;item($j)-&gt;textContent . "&lt;br /&gt;";
          }
      }
  }
  
  
  ?&gt; 
  </code></pre>
  
  <p>when I paste "someurl" insted of <code>$lin</code> it work but the other way doesn't. I've tried to do <code>$html = file_get_contents($alllinks[$i]);</code> but it didn't work, I don't know why.</p>