次のコードスニペットがあります。これは基本的にブログサイトを解析し、いくつかの情報を変数として保存します。
global $articles;
$items = $html->find('div[class=blogpost]');
foreach($items as $post) {
$articles[] = array($post->children(0)->innertext,
$post->children(1)->first_child()->outertext);
}
foreach($articles as $item) {
echo $item[0];
echo $item[1];
echo "<br>";
}
上記のコードは次のように出力されます。
Title of blog post 1 <script type="text/javascript">execute_function(3,'')</script><a href="http://www.example.com/cool_news" id="963" target="_blank" >Click here for news</a> <img src="/news.gif" width="12" height="12" title="validated" /><span class="title">
Title of blog post 2 <script type="text/javascript">execute_function(3,'')</script><a href="http://www.example.com/neato" id="963" target="_blank" >Click here for neato</a> <img src="/news.gif" width="12" height="12" title="validated" /><span class="title">
Title of blog post 3 <script type="text/javascript">execute_function(3,'')</script><a href="http://www.example.com/lame" id="963" target="_blank" >Click here for lame</a> <img src="/news.gif" width="12" height="12" title="validated" /><span class="title">
$ item [0]には「ブログ投稿Xのタイトル」が含まれ、$item[1]には残りが含まれます。
私がやりたいのは、$ item [1]を解析し、それに含まれるURLのみを別の変数として保持することです。おそらく私は自分の質問を正しく表現していませんが、これを理解するのに役立つものは何も見つかりません。
誰か助けてもらえますか?