我正在尝试使用以下代码从多维数组中打印信息:
$url = $_POST['fromtheformandworking'];
$urls_array = get_headers($url,1);
$count_location = count($urls_array["Location"]);
for ($i=0; $i > $count_location ; $i++) {
echo $urls_array["Location"]["$i"];
}
它没有返回任何东西。有谁知道我哪里做错了?感谢。
跟踪来自Web服务器输出的所有http响应的函数是:
Array
(
[0] => HTTP/1.1 301 Moved Permanently
[Date] => Array
(
[0] => Fri, 29 May 2015 10:38:17 GMT
[1] => Fri, 29 May 2015 10:38:18 GMT
[2] => Fri, 29 May 2015 10:38:18 GMT
[3] => Fri, 29 May 2015 10:38:19 GMT
)
[Server] => Array
(
[0] => Apache
[1] => Apache
[2] => Apache
[3] => Apache
)
[Location] => Array
(
[0] => http://www.cfcarehospitalar.com.br/produtos/cadeira-de-rodas-avd-aluminio-reclinavel-ortobras/
[1] => http://www.cfcarehospitalar.com.br/cadeira-de-rodas-avd-aluminio-reclinavel.html.html
[2] => http://www.cfcarehospitalar.com.br/
)
[Vary] => Array
(
[0] => Accept-Encoding
[1] => Accept-Encoding
[2] => Accept-Encoding
[3] => Accept-Encoding
)
[Content-Length] => Array
(
[0] => 375
[1] => 370
)
[Connection] => Array
(
[0] => close
[1] => close
[2] => close
[3] => close
)
[Content-Type] => Array
(
[0] => text/html; charset=iso-8859-1
[1] => text/html; charset=iso-8859-1
[2] => text/html; charset=UTF-8
[3] => text/html; charset=UTF-8
)
[1] => HTTP/1.1 301 Moved Permanently
[2] => HTTP/1.1 302 Moved Temporarily
[X-Powered-By] => Array
(
[0] => PHP/5.3.3-7+squeeze19
[1] => PHP/5.3.3-7+squeeze19
)
[Expires] => Array
(
[0] => Thu, 19 Nov 1981 08:52:00 GMT
[1] => Thu, 19 Nov 1981 08:52:00 GMT
)
[Cache-Control] => Array
(
[0] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
[1] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0
)
[Pragma] => Array
(
[0] => no-cache
[1] => no-cache
)
[Set-Cookie] => Array
(
[0] => frontend=g42hn3qgu179rib57kot3looa4; expires=Sat, 30-May-2015 10:38:18 GMT; path=/; domain=www.cfcarehospitalar.com.br; HttpOnly
[1] => frontend=m9fsajlpkf6svr0ejaojr1v205; expires=Sat, 30-May-2015 10:38:19 GMT; path=/; domain=www.cfcarehospitalar.com.br; HttpOnly
)
[3] => HTTP/1.1 200 OK
)
答案 0 :(得分:0)
你的for循环中有错误,应该是
for ($i=0; $i < $count_location ; $i++) {
echo $urls_array["Location"]["$i"];
}