I am learning PHP and I'm trying to understand the array below, I need to grab content-type , it should give me
Anyone good with arrays could you please help?
array(
[0] => HTTP/1.1 200 OK
[1] => Date: Sat, 30 Aug 2014 17:10:12 GMT
[2] => Server: Apache
[3] => X-Gas_TTL: 900
[4] => Cache-Control: max-age=900
[5] => X-GasHost: gas1.usw
[6] => X-Cooking-With: Gasoline-Local
[7] => X-Gasoline-Age: 844
[8] => Last-Modified: Sat, 30 Aug 2014 16:56:08 GMT
[9] => Content-Type: text/xml;charset=UTF-8
[10] => Vary: Accept-Encoding
)
Thank you in advance
Regards, Mona
.*?Content-Type:\s*(.*?=(.*?))\n.*
With s flag on this will give what's required.
See demo.
The array must be in a variable ( I assume, since you seem to have printed it ), so you simply print/echo the value you're after.
echo $someArrayVariable[9];
Where someArrayVariable is a variable that contains the array.
That is assuming it is in a variable in the first place.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.