title: php cURL. preg_match , extract text from xhtml
body: <p>I'm trying to extract the price from the bellow html page/link using php cURL and preg_match . Basically I'm expecting for this code to output 4,550 but for some reasons I get</p>
  
  <pre> Notice: Undefined offset: 1 in C:\wamp\www\test.php on line 22</pre>
  
  <p>I think that the pattern is correct because if I put the html itself in a variable and escape the "" it works ! .
    Also if I output (echo $result;) it displays the html properly grabbed from foxtons website so I just can't figure it out why the whole thing doesn't work . I need to make this work and also I would appreciate if you would tell me why is that notice generated and why my current script  doesn't work.</p>
  
  <p><pre>
  $url = "<a href="http://www.foxtons.co.uk/search?bedrooms_from=0&amp;property_id=727717" rel="nofollow noreferrer">http://www.foxtons.co.uk/search?bedrooms_from=0&amp;property_id=727717</a>";
  $ch = curl_init($url);</p>
  
  <p>curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); 
  $result = curl_exec($ch);
  curl_exec($ch);
  curl_close($ch);
  $result2 = str_replace('"', '\"', $result);</p>
  
  <p>$tagname1= ");&lt;/script>
      ";
   $tagname2= "&lt;/noscript> 
      per month&lt;/a>";</p>
  
  <code>$pattern = "/$tagname1(.*?)$tagname2/";
  preg_match($pattern, $result, $matches);
  $prices = $matches[1];
  
  print_r($prices);
  
  ?&gt;
  </code></pre>
  
  <p></p>