プロが教えるわが家の防犯対策術!

Notice: Undefined offset: 2 in C:\xampp\htdocs\news2.php on line 18

Warning: file_get_contents(): Filename cannot be empty in C:\xampp\htdocs\news2.php on line 19

プログラミング超初心者です。var_dumpしてみてもarray[2]は存在していたのですが・・・。
なぜこのようなエラーが出るのか、またどのように解決すればよいのでしょうか。わかる方、教えてください。よろしくお願いします。

<?php

$newstop="http://headlines.yahoo.co.jp/hl";
$html=file_get_contents($newstop);
$patern1='/http.*c=bus/';
preg_match($patern1,$html,$matches1);
//var_dump($matches1);


$newstop2=($matches1[0]);
$html2=file_get_contents($newstop2);
//echo($html2);
//!ここまでで経済面のトップページはとってこれた

//ここから、記事全文を拾う
$fullpattern='/http.*all/';
preg_match_all($fullpattern,$html2,$matches3);
$fullurl=($matches3[2]); ※ここが18行目
$fulltext=file_get_contents($fullurl);       ※ここが19行目
echo ($fulltext);
//var_dump($matches3);


?>

A 回答 (1件)

惜しい。

$matches3[2]ではなく$matches3[0][2]です。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!