PHPのおさらい9 外部ファイルの読込

試作中

<?php

$geturl = "https://card.yahoo.co.jp/campaign/";

//コンテンツ用配列の初期化
$ary_matchcontent = array();

//リクエスト先がないときwarningが発生するので@で抑えている。
$source = @file_get_contents($geturl);
        //if($geturl !== false){
          if($geturl){
	    //ページの一部を取得
          preg_match('/<h2>.+</a>/', $source, $matches);
          //preg_match('!<div id="whatsnew">\s*(.*)</div>!s', $source, $matches);
          //$ret = $matches[0];
          //配列に追加
          $ary_matchcontent[] = $matches[0];
		
        if($html != ""){
		//存在せず
              echo $geturl.'が存在しません';
	}


?>

<?php
/*
if (preg_match('!<div id="whatsnew">\s*(.*)</div>!s', $str, $res)){
  print $res[1];
}
*/

//複数条件でマッチング
<?php
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",
    "<b>example: </b><div align=\"left\">this is a test</div>",
    $out, PREG_SET_ORDER);
echo $out[0][0] . ", " . $out[0][1] . "\n";
echo $out[1][0] . ", " . $out[1][1] . "\n";
?>


//ランダムインクルードの良い方法
include_once("./". rand(1,5) .".php");
?>