Skip to content

Instantly share code, notes, and snippets.

@epierpont
Last active October 5, 2020 16:25
Show Gist options
  • Save epierpont/aef99bf1aa448b4aaab132ad2fce725f to your computer and use it in GitHub Desktop.
Save epierpont/aef99bf1aa448b4aaab132ad2fce725f to your computer and use it in GitHub Desktop.
PHP URL 404 loop
<?php
// Loop through URL array and look for 404 results.
$url_array = ['https://facebook.com/','https://googlemaps.com/','https://gigglemips54252.com/', 'https://www.airbnb.com/'];
foreach ($url_array as $url_entry) {
$file_headers = @get_headers($url_entry);
$exists = !$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found' ? false : true;
echo $exists;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment