現在、preg_matchを使用して1つの値を取得しようとしています(複数の値を取得する前に)。 print_r()を実行すると、配列に何も格納されません。ここでPHP - preg_matchを使用してWebページからDIV要素をスクラップする
は私がこれまでにしようとしています何私のコードです:
<?php
$content = '<div class="text-right font-90 text-default text-light last-updated vertical-offset-20">
Reported ETA Received:
<time datetime="2017-02-02 18:12">2017-02-02 18:12</time>
UTC
</div>';
preg_match('|Reported ETA Received: <time datetime=".+">(.*)</time>(.*)\(<span title=".+">(.*)<time datetime=".+">(.*)</time></span>\)|', $content, $reported_eta_received);
if ($reported_eta_received) {
$arr_parsed['reported_eta_received'] = $reported_eta_received[1];
}
?>
必要な出力:
2017-02-02 18:12
私の上記のコードは動作しません。これに関する助けをいただければ幸いです。前もって感謝します。
チェックアウトのDOMDocument http://stackoverflow.com/questions/10366458/php-dom-parsing-a-html-list-into-an-array – Nitin