$re = '/HTTP\/\d\.\d\s(\d{3})/';
$str = 'HTTP/1.1 302 See other
Date: Tue, 17 Feb 2015 20:20:48 GMT
Server: Apache
X-Powered-By: PHP/5.5.21
Set-Cookie: 5e8627afafd16a920dac4dbb644715a5=ue1gprimq6rb5r4qsb8sk28jb2; path=/; HttpOnly
Location: http://fake.dk/da/
Connection: close
Content-Type: text/html; charset=utf-8
Set-Cookie: SERVERID=; path=/
HTTP/1.1 200 OK
Date: Tue, 17 Feb 2015 20:20:48 GMT
Server: Apache
X-Powered-By: PHP/5.5.21
Set-Cookie: 76726d50abd3edd601ecfbc19fe61c87=da-DK; path=/
Set-Cookie: 76726d50abd3edd601ecfbc19fe61c87=da-DK
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Last-Modified: Tue, 17 Feb 2015 20:20:48 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: close
Content-Type: text/html; charset=utf-8
Set-Cookie: SERVERID=; path=/
<!doctype html>
<html lang="da">
<head>
</head>
<body>
</body>
</html>';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php