I have a specific URL that I would like a scaript to change 1 digit of the URL by counting up and every time the link is valid I want it to save that link and continute on. If the link is invalid it will just say page no availible, if it is valid then it will redirect to a new URL. Because of this I can't seem to get a viable PHP script. But maybe there is an easier way to do this... Here is what I tried so far as was unsucessful with: <?php $context = stream_context_create( array( 'http' => array( 'follow_location' => true ) ) ); $start = $_GET['start']; $end = $_GET['end']; echo 'Testing urls starting with: ' . 'https://www.******.***/***/1234567/***' . $start . '<br/>'; for ($i = $start; $i <= $end; $i++) { $url = 'https://www.*******.***/***/G964999422' . $i . '/***'; $html = file_get_contents($url, false, $context); if ($i == $start) echo $html; PHP: Please help!
<?php // setup curl $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_HEADER, true); // where to start and when to stop $start = 1; $end = 100; foreach (range($start, $end) as $current) { // current url $url = "http://example.com/{$current}"; curl_setopt($curl, CURLOPT_URL, $url); curl_exec($curl); // get http code from header $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); // check if http code is not successfull (read more here: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) if ($httpCode != 200) { echo "Something is wrong with {$url}\n"; } } curl_close($curl); PHP: Also I noticed what you get $start and $end from $_GET array. Run this kind of scripts from terminal. This way you will see results instantly, without browser loading screen.