title: How to use cURL to fetch text
body: <p>I'm trying to grab/fetch text from another URL using cURL. The location of where I grab the text from is within a blank HTML document with dynamic (not static) data, therefore there are no HTML tags to filter. This is what I've got so far:</p>
  
  <pre><code>$c = curl_init('http://url.com/dataid='.$_POST['username']);
  curl_setopt(CURLOPT_RETURNTRANSFER, true);
  curl_setopt(CURLOPT_FRESH_CONNECT, true);
  
  $html = curl_exec($c);
  
  if (curl_error($c))
  die(curl_error($c));
  
  // Get the status code
  $status = curl_getinfo($c, CURLINFO_HTTP_CODE);
  
  curl_close($c);
  </code></pre>
  
  <p>This works perfectly, however at the end of dynamic HTML document there is un-required text, "<strong>#endofscript</strong>" (without quotations). This gets grabbed/fetched, so what can be done to not grab that? I've tried looking at "<strong>strpos</strong>" and such but I'm unsure on how to integrate that with cURL.</p>
  
  <p>All/Any help will/would be appreciated. <strong>:)</strong></p>
  
  <p>EDIT: The code I'm currently using:</p>
  
  <pre><code>&lt;?php
  
  $homepage = file_get_contents('http://stackoverflow.com/');
  
  $result = substr("$homepage", 0, -12);
  
  echo $result;
  
  ?&gt;
  </code></pre>