我正在尝试解析 HTTP 文档以提取文档的部分内容,但无法获得所需的结果。这是我得到的:
<?php
// a sample of HTTP document that I am trying to parse
$http_response = <<<'EOT'
<dl><dt>Server Version: Apache</dt>
<dt>Server Built: Apr 4 2010 17:19:54
</dt></dl><hr /><dl>
<dt>Current Time: Wednesday, 10-Oct-2012 06:14:05 MST</dt>
</dl>
I do not need anything below this, including this line itself
......
EOT;
echo $http_response;
echo '********************';
$count = -1;
$a = preg_replace("/(Server Version)([\s\S]*?)(MST)/", "$1$2$3", $http_response, -1, $count);
echo "<br> count: $count" . '<br>';
echo $a;
- 我仍然在输出中看到字符串“我不需要...”。我不需要那个字符串。我究竟做错了什么?
- 如何轻松删除所有其他 HTML 标记?
谢谢你的帮助。
-阿米特