使用cURL获取以下字符串。 代码可以在此评论中找到。
HTTP/1.1 200 OK ID=347 Date: Tue, 19 Feb 2013 09:15:25 GMT Server:
Apache/2.2.22 (Ubuntu) Content-length: 0 Vary: Accept-Encoding
Content-Type: text/plain; charset=ISO-8859-1
现在我需要从字符串中获取ID,为此我使用了explode将空格分隔符转换为数组,如下所示:
$getIdElem = explode(' ',$output);
echo '<pre>';print_r($getIdElem);
但是我在使用具有空格的ID字符串时,得到了带有Date:的结果。打印数组的输出如下:
Array
(
[0] => HTTP/1.1
[1] => 200
[2] => OK
[3] => ID=347
Date:
[4] => Tue,
[5] => 19
[6] => Feb
[7] => 2013
[8] => 09:15:25
[9] => GMT
Server:
[10] => Apache/2.2.22
[11] => (Ubuntu)
Content-length:
[12] => 0
Vary:
[13] => Accept-Encoding
Content-Type:
[14] => text/plain;
[15] => charset=ISO-8859-1
)
我不理解为什么explode函数中不包括该空格。有人能帮忙解释一下吗?
explode("\n", $output)
- str