Jump to content

cURL problem


Ex1t

Recommended Posts

I have this code

        $url = 'www.site.com'; 
        $list = array("ext.pdf", "ext_1.pdf", "ext_2.pdf", "ext_3.pdf", "ext_4.pdf"); 

        foreach($list as $lists) 
        { 
          $ch = curl_init(); 
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
          curl_setopt($ch, CURLOPT_HEADER, 1); 
          curl_setopt($ch, CURLOPT_URL, $url.$lists); 
          $result = curl_exec($ch); 
          curl_close($ch); 

          if (preg_match("/200 OK/", $result)){ 
              echo "<p>$url$lists</p>"; 
          } 
          else if (preg_match("/401 Unauthorized/", $result)) { 
              echo "<p>$url$lists</p>"; 
          }  

       } 

Now, if this script finds nothing i want to echo 'Not found'..
I can do it with 'else' but it displays 5 times..
I tried with exit() but there is also problem.. Help please

Link to comment
https://forums.phpfreaks.com/topic/297623-curl-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.