I have a string which contains multiple lines, e.g.
–f45e4e11-B–
POST /form/ HTTP/1.1
Host: server.domain.com
Connection: keep-alive
Content-Length: 502
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xm’
I want to extract the hostname (server.domain.com) from the string. This line will always start with "Host: " but the lines themselves may not always be in the same order. I have no idea what the best way to achieve this might be. I’ve looked at preg_replace and substr but can’t work out how to achieve this. The one thing I did work out was how to find the strpos of the start of the bit I want, but not sure how to work it out for the end of the line. Any suggestions or help would be welcome.
Thanks
Mark