のようなものを試してください
preg_match('#^HTTP\/1\.(0|1)\s401#i', $yourheaders, $match);
if(!empty($match) && !is_null($match[1])){
echo "failed";
}else{
echo "ok";
}
得た:
HTTP/1.1 500 Internal Server Error Set-Cookie: cprelogin=no;.
HttpOnly; path=/; port=2082 Set-Cookie:.
cpsession=%3aXYBHer1OXxaqzCNVLHNR3ujtmdkZow6PYsnyE8daVUF1lq8fQBiFd7EeHJ99CK93;.
HttpOnly; path=/; port=2082 Server: cpsrvd/11.34.1.4 Content-type: text/html;
ok
Array
(
)
401:
HTTP/1.1 401 Access Denied Set-Cookie: cprelogin=no;
HttpOnly; path=/; port=2082 Set-Cookie:
cpsession=%3aXYBHer1OXxaqzCNVLHNR3ujtmdkZow6PYsnyE8daVUF1lq8fQBiFd7EeHJ99CK93;
HttpOnly; path=/; port=2082 Server: cpsrvd/11.34.1.4 Content-type: text/html;
failed
Array
(
[0] => HTTP/1.1 401
[1] => 1
)