3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php function parseHeaders($headers) { $headers = preg_split("/(\r|\n)+/", $headers, -1, PREG_SPLIT_NO_EMPTY); $parse_headers = array(); for ($i = 1; $i < count($headers); $i++) { list($key, $raw_value) = explode(':', $headers[$i], 2); $key = trim($key); $value = trim($raw_value); if (array_key_exists($key, $parse_headers)) { // See HTTP RFC Sec 4.2 Paragraph 5 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 // If a header appears more than once, it must also be able to // be represented as a single header with a comma-separated // list of values. We transform accordingly. $parse_headers[$key] .= ',' . $value; } else { $parse_headers[$key] = $value; } } return $parse_headers; } print_r(parseHeaders('HTTP/1.1 200 OK x-amz-id-2: VY3SprXJgsllfuyxECb2ykYo74ZQO/V+cbGadSo/FFt1VysYO+f66gb18XM9h0LOnl4wei6XSdc= x-amz-request-id: 00B4612940F92DAF Date: Tue, 05 Jan 2016 20:50:25 GMT ETag: "9d3213e68a63ed25415b44031ccf6a37" Content-Length: 0 Server: AmazonS3'));
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '<', expecting end of file in /in/GAkZM on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected '<' in /in/GAkZM on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '<' in /in/GAkZM on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/GAkZM on line 3
Process exited with code 255.

preferences:
228.47 ms | 1395 KiB | 153 Q