title: Checking whether a pdf file is present on the url?
body: <pre><code>&lt;?php
  set_time_limit(0);
  $url  = 'http://www.some.url/file.pdf';
  $path = 'files/file.pdf';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $data = curl_exec($ch);
  curl_close($ch);
  file_put_contents($path, $data);
  ?&gt;
  </code></pre>
  
  <p>This is the code that I use to download a particular pdf file froma given url.
  What if there a many files in that url by names file1.pdf, file2.pdf etc. How can I check while running a loop, when to end the loop as the files will be present up to a limited number ?</p>
  
  <p>Please help!</p>