如果存在,如何检查多个网址?

时间:2012-05-19 07:47:01

标签: php url hyperlink fopen

在StackOverflow上的

我发现了如何检查是否存在一个url:

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

如何使用数组和while循环?

这样我就可以查看超过1个网址。

例如,它可以检查50个网址吗?

1 个答案:

答案 0 :(得分:2)

只需使用foreach循环:

foreach ($urlsArray as $url) {
  if(@fopen($url,'r')){
    echo 'Exist';
  }
  else {
      echo 'Doesnt exist';
  }
}