title: RegExp Not providing expected result with cURL
body: <p>Hi below is my code which is not providing expected result.</p>
  
  <p>First it should provide complete html content of page using <code>cURL</code> then using regexp which is providing expected result when I provide them direct <code>htmlcontent</code> but not providing same result using curl. </p>
  
  <p>Suppose When I pass below content to <code>htmlcontent</code> variable then <code>RegExp</code> providing proper result. </p>
  
  <pre><code>$htmlContent = '&lt;table id="ctl00_pageContent_ctl00_productList" class="product-list" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"&gt;
                      &lt;tr&gt;
                          &lt;td class="product-list-item-container" style="width:100%;"&gt;
          &lt;div class="product-list-item" onkeypress="javascript:return WebForm_FireDefaultButton(event, &amp;#39;ctl00_pageContent_ctl00_productList_ctl00_imbAdd&amp;#39;)"&gt;
                                          &lt;a href="/W10542314D/WDoorGasketandLatchSt.aspx"&gt;
                &lt;img class="product-list-img" src="/images/products/display/applianceparts.jpg" title="W10542314 D/W Door Gasket &amp; Latch St  " alt="W10542314 D/W Door Gasket &amp; Latch St  " border="0" /&gt;
              &lt;/a&gt;
                  &lt;div class="product-list-options"&gt;
            &lt;h5&gt;&lt;a href="/W10542314D/WDoorGasketandLatchSt.aspx"&gt;W10542314 D/W Door Gasket &amp;amp; Latch St&lt;/a&gt;&lt;/h5&gt;
   &lt;div class="product-list-cost"&gt;&lt;span class="product-list-cost-label"&gt;Online Price:&lt;/span&gt; &lt;span class="product-list-cost-value"&gt;$33.42&lt;/span&gt;&lt;/div&gt;
                                    &lt;/div&gt;
  '; 
  </code></pre>
  
  <p>Below is my complete code - </p>
  
  <pre><code>&lt;?php
  $url = "http://www.universalapplianceparts.com/search.aspx?find=W10130694";
  $ch1= curl_init();
  curl_setopt ($ch1, CURLOPT_URL, $url );
  curl_setopt($ch1, CURLOPT_HEADER, 0);
  curl_setopt($ch1,CURLOPT_VERBOSE,1);
  curl_setopt($ch1, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
  curl_setopt ($ch1, CURLOPT_REFERER,'http://www.google.com');  //just a fake referer
  curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch1,CURLOPT_POST,0);
  curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 20);
  
  $htmlContent= curl_exec($ch1);
  echo $htmlContent;
  
  
  $value=preg_match_all('/.*&lt;div.*class=\"product\-list\-options\".*&gt;.*&lt;a href="(.*)"&gt;.*&lt;\/a&gt;.*&lt;\/div&gt;/s',$htmlContent,$matches);
  print_r($matches);
  
  $value=preg_match_all('/.*&lt;div.*class=\"product\-list\-item\".*&gt;.*&lt;a href=\"(.*)\"&gt;.*&lt;img.*&gt;.*&lt;\/div&gt;/s',$htmlContent,$matches);
  print_r($matches);
  </code></pre>
  
  <p>In this code it echo htmlcontent of webpage then with regexp it should return <code>href</code> of anchor tag between div which class name is <code>product-list-options</code> and <code>product-list-item</code></p>
  
  <p>Current output is - </p>
  
  <pre><code>http://www.universalapplianceparts.com/termsofservice.aspx
  </code></pre>
  
  <h2>Here Regexp reading my html content from cURL in reverse order and returning first href value in anchor tag.</h2>
  
  <p>Expected output in array value - <code>/W10130694LatchAssyWhiteHandle.aspx</code></p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks  </p>