<?php function url_exists($url) { // Version 4.x supported $handle = curl_init($url); if (false === $handle) { return false; } curl_setopt($handle, CURLOPT_HEADER, false); curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox curl_setopt($handle, CURLOPT_NOBODY, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, false); $connectable = curl_exec($handle); curl_close($handle); return $connectable; } for($i=0; $licznik>$i; $i++) { $filename = 'http://localhost/media/catalog/product'.$plik1[$i]; $test = url_exists($filename); if ($test==1) else } ?>
test.txt
/Sphinx/206913_m.jpg /Sphinx/206914_m.jpg /Sphinx/208418_m.jpg /Sphinx/208669_m.jpg /Sphinx/208671_m.jpg /Sphinx/208672_m.jpg /Sphinx/441224_m.jpg