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;
- 出力に「Inneet...」という文字列が表示されます。その文字列は必要ありません。私は何が間違っているのですか?
- 他のすべてのHTMLタグも簡単に削除するにはどうすればよいですか?
ご協力いただきありがとうございます。
-アミット