I am building a script thats goal is to check up to 100 URLS for validity (No 404).
The only variable in the URL is the page number, like so:
http://example.com/category/id/products/page/1
http://example.com/category/id/products/page/2
and so on up to 100,
as soon as my code reaches an invalid URL, I want it to stop and echo the number it has reached, this is the code I am trying to no avail:
$url ="http://example.com/category/id/products/page/1";
if (false !== strpos($url, $id)) {
$pageNumber = 2;
$check = true;
do{
$urlIterate = "http://example.com/category/id/products/page/".$pageNumber;
if(false !== strpos($urlIterate, $id)){
$pageNumber++;
}
else{
$check = false;
}
}
while($pageNumber <= 99);
}
else{
$check = false;
echo 'No pages were found at all';
}
echo "There were ". $pageNumber." pages.;
?>