I have an array $headers
that looks like this and I want to extract the server name only. The problem is the data is not always in the same order so I need to search for "Server" and return its value. I imagine i need to use a loop but cant figure out how to incorporate the search.
Sample of array $headers
array(13) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(19) "Server: nginx/1.6.2"
[2]=>
string(35) "Date: Fri, 08 May 2015 14:27:28 GMT"
[3]=>
string(38) "Content-Type: text/html; charset=utf-8"
[4]=>
string(17) "Connection: close"
[5]=>
string(25) "X-Powered-By: PHP/5.6.7-1"
[6]=>
string(44) "Last-Modified: Fri, 08 May 2015 14:20:12 GMT"
}
I would like to extract the server name nginx/1.6.2
Here is my loop that I need to build upon
foreach ($headers as $value) {
echo "$value
";
}