title: PHP: SoapClient Response code from HTTP headers
body: <p>I'm trying to extract the Soap response's HTTP status code.
  So for instance i have :</p>
  
  <pre><code>$client = new SoapClient($wsdl);
  $client-&gt;__setSoapHeaders(
      new SoapHeader(
          $nameSpace,
          'Security',
          $secHeaderValue,
          true
      )
  );
  
  // The actual call
  $response = $client-&gt;Complete($paramswebservice)
  </code></pre>
  
  <p>So now i'm getting the response headers, this way :</p>
  
  <pre><code>$responseHeaders = $client-&gt;__getLastResponseHeaders();
  var_dump($responseHeaders);
  </code></pre>
  
  <p>This is the result of the vardump : a string formatted this way (web browser - page source code) </p>
  
  <p><a href="https://i.stack.imgur.com/7L7GR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7L7GR.png" alt="enter image description here"></a></p>
  
  <p><strong>What i am doing right now to extract the http status code '200' :</strong></p>
  
  <pre><code>/**
   * 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];
  }
  </code></pre>
  
  <p>I really don't like this solution. I would like a more robust / consistent one. Any suggestions ?</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>As asked in the comments : </p>
  
  <pre>
  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 </pre>