我需要将数组中的“日期”保存到 php 变量中。(get_headers) 数组有 2 种类型。
类型1
Array
(
[0] => HTTP/1.1 302 Object Moved
[Content-Type] => Array
(
[0] => text/html
[1] => text/html;charset=UTF-8
)
[1] => HTTP/1.1 200 OK
[Date] => Thu, 27 Jun 2013 06:50:37 GMT
类型2
Array
(
[0] => HTTP/1.1 301 Moved Permanently
[Date] => Array
(
[0] => Thu, 27 Jun 2013 06:50:27 GMT
[1] => Thu, 27 Jun 2013 06:41:59 GMT
)
这是我切片的方法:
$arr = array();
$arr = get_headers($url,1);
$date_variable = $arr[Date];
if($date_variable == 'Array'){
$date = $arr[Date][0];
}
else {
$date = $arr[Date];
}
我的切片非常难看.. $date_variable == 'Array' 不起作用..