No i co jest źle?
$text = array(
'http://onet.pl/404',
'http://4programmers.net/404',
'http://a.pl/'
);
foreach ($text as $url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$return = curl_exec($ch);
$header = explode("\n",$return);
var_dump($header);
}
array (size=6)
0 => string 'HTTP/1.1 301 Moved Permanently
' (length=31)
1 => string 'location: http://www.onet.pl
' (length=29)
2 => string 'server: edgeserver
' (length=19)
3 => string 'Connection: keep-alive
' (length=23)
4 => string '
' (length=1)
5 => string '' (length=0)
array (size=11)
0 => string 'HTTP/1.1 404 Not Found
' (length=23)
1 => string 'Connection: close
' (length=18)
2 => string 'Date: Wed, 25 Sep 2013 12:13:06 GMT
' (length=36)
3 => string 'Server: Cherokee
' (length=17)
4 => string 'X-Using-Wrapper: Yes
' (length=21)
5 => string 'Set-Cookie: sid=a4c21dd747c3f; expires=Thu, 25-Sep-2014 18:01:52 GMT; path=/; domain=.4programmers.net; httponly
' (length=132)
6 => string 'Set-Cookie: sid=a4c21dd74e517c3f; expires=Thu, 25-Sep-2014 18:01:52 GMT; path=/; domain=.4programmers.net; httponly
' (length=132)
7 => string 'Content-type: text/html
' (length=24)
8 => string 'X-Powered-By: chomiki
' (length=22)
9 => string '
' (length=1)
10 => string '' (length=0)
array (size=12)
0 => string 'HTTP/1.1 200 OK
' (length=16)
1 => string 'Cache-Control: private
' (length=23)
2 => string 'Content-Length: 49334
' (length=22)
3 => string 'Content-Type: text/html; charset=utf-8
' (length=39)
4 => string 'Server: Microsoft-IIS/7.5
' (length=26)
5 => string 'X-AspNetMvc-Version: 4.0
' (length=25)
6 => string 'X-AspNet-Version: 4.0.30319
' (length=28)
7 => string 'Set-Cookie: __Apl_Data=yowtaJxPZWw1Du6dlV1wnnsiyzz2IVpQ5rxjp_aZc6rVTO35kpEwu5tFXmiUaLzq0; expires=Thu, 25-Sep-2014 12:13:06 GMT; path=/
' (length=136)
8 => string 'X-Powered-By: ASP.NET
' (length=22)
9 => string 'Date: Wed, 25 Sep 2013 12:13:06 GMT
' (length=36)
10 => string '
' (length=1)
11 => string '' (length=0)