title: Looking for "stock_value" in a HTML page - preg_match stuff
body: <p>I have a URL of a HTML page that shows few products (pens, tshirts, etc), with stocks (products in warehouse).</p>
  
  <p>I need to get (steal) the stock for a particular SKU_CODE corresponding to a product, since I've spoken via email with them and they don't have a .CSV / .TXT or Excel file with stocks.
  So I need to load HTML from a dynamic URL and parse it with preg_match_all to get the external stock, and then display it on my website page, corresponding to a particular product.</p>
  
  <p>It's similar to getting the current currency parity from a bank site, when you need to put it on your website, if you code it by hand.</p>
  
  <p>So here it is, my code, which works only half. I managed to locate the SKU_CODE on the page, but when I look for the stock value, it shows Array() if i do a print_r and then i cannot get a hold on any value of that array. I'll post my code below.</p>
  
  <p>$code = 'AP731463-10';
      $code_minimized = explode("-", $code);</p>
  
  <pre><code>$url_to_get = 'http://www.andapresent.hu/index.php?term_idk_list=4776829&amp;term_idk_l=&amp;filt=&amp;qs='.$code_minimized[0].'';
  
  function findinside($start, $end, $string) {
      preg_match_all('/' . preg_quote($start, '/') . '([^\.)]+)'. preg_quote($end, '/').'/i', $string, $m);
      return $m[1];
  }
  
  
      $array_lines = file($url_to_get);
      //echo($array_lines[1654]);
  
      $cont = 0;
      $found_match = 0;
  
      while(isset($array_lines[$cont])){
  
          //daca inca nu s-a gasit codul cautat, cauta-l intre &lt;b&gt; &lt;/b&gt;
          //if code we're looking for is not yet found, search between &lt;b&gt; &lt;/b&gt;
  
          if($found_match==0){
              $out = findinside('&lt;b&gt;','&lt;/b&gt;', $array_lines[$cont]);
          }
  
          //o data ce s-a gasit, flag set ca sa nu-l mai caute inca o data
          //once found, set flag $found_match so it will not look for it next time
          if($out[0]==$code &amp;&amp; $found_match==0){
              $found_match = 1;
              echo "Found match : ".$code." = ".$out[0]."&lt;br&gt;";
          }
  
          //daca e flag-ul gasit e setat, cauta next info (stock-ul) pana il gaseste in $array_lines[$cont]
          //if flag is already set, look for next info (the stock value of the product)
          if($found_match==1){
              $out_2 = findinside('&lt;td class="szoveg_k" align="center"&gt;','&lt;/td&gt;', $array_lines[$cont]);
              echo $out_2;
          }
  
  
          $cont++;
      }
  </code></pre>