PHP:来自 HTTP headers 的 SoapClient 响应代码

PHP: SoapClient Response code from HTTP headers

我正在尝试提取 Soap 响应的 HTTP 状态代码。 所以例如我有:

$client = new SoapClient($wsdl);
$client->__setSoapHeaders(
    new SoapHeader(
        $nameSpace,
        'Security',
        $secHeaderValue,
        true
    )
);

// The actual call
$response = $client->Complete($paramswebservice)

所以现在我收到回复 headers,这样:

$responseHeaders = $client->__getLastResponseHeaders();
var_dump($responseHeaders);

这是 vardump 的结果:以这种方式格式化的字符串(网络浏览器 - 页面源代码)

我现在正在做什么以提取 http 状态代码“200”:

/**
 * Returns the HTTP Status code of $response
 * @param string $response
 * @return string
 */
function extract_response_http_code($response) {
    $tmp = explode('\n', $response);
    $array = explode(' ', $tmp[0]);

    return $array[1];
}

我真的不喜欢这个解决方案。我想要一个更健壮/一致的。有什么建议吗?

编辑 1

如评论中所问:

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Length: 1315
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Thu, 30 Mar 2017 08:52:15 GMT 

PHP code demo

<?php
$result="HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Length: 1315
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Thu, 30 Mar 2017 08:52:15 GMT";
preg_match("/HTTP\/\d\.\d\s*\K[\d]+/", $result,$matches);
print_r($matches);

输出:

Array
(
    [0] => 200
)