1

on StackOverflow I found out how to check if just one url exist:

if (@fopen($url,'r')){
    echo 'Exist';
}
else {
    echo 'Does not exist';
}

How to use this with an array and perhaps with the while loop?

So that I can check for more than 1 URL.

For example, so that it can check 50 URLs?

tohuwawohu
  • 13,268
  • 4
  • 42
  • 61
  • Why are you suppressing errors? http://stackoverflow.com/a/960288/871050 Don't suppress errors – Madara's Ghost May 19 '12 at 07:48
  • Because fopen will emit a warning if the URI does not exist, and return false. The @ in this case is justified, assuming fopen must be used (I'd use cURL for this). – Artefact2 May 20 '12 at 13:35

1 Answers1

1

Just use foreach loop:

foreach ($urlsArray as $url) {
  if(@fopen($url,'r')){
    echo 'Exist';
  }
  else {
      echo 'Doesnt exist';
  }
}
Kane Cohen
  • 1,790
  • 12
  • 17