Dreamweaver TechniqueJAVA Script サンプル | CSS sample | JAVA Applet sample | Flash Sample
HTML4.0 reference | DynamicHTMLXHTML | XML sample | XSLT sample | RIKO's ASP Trial
ASP ADO リファレンス | PHP関数リファレンス | MySQL関数リファレンス

HTMLファイルからタグを取り除く

■ HTMLファイルからタグを取り除く

fgetss関数を使うと、読み取った行からHTMLタグを取り除くことができます。

文字列 = fgetss(ハンドル, [バイト数], [タグ])

オプションの「タグ」にタグ名を列挙することにより、取り除かないタグを指定することができます。

<?php
   define("TEST_FILE", "./test/test/193.html");<
   header("Content-Type: text/html; charset=EUC-JP");

   print "<pre>";

   $s = file_get_contents(TEST_FILE) or die("ファイルを開けません\n");
   print "クオ、ホ・ス。シ・ケ。ァ\n";
   print htmlspecialchars($s, ENT_NOQUOTES);
   print "\n";

   print "一部のタグを除きHTMLタグを取り去る:\n";
   $fp = fopen(TEST_FILE, "r") or die("・ユ・。・、・・ウォ、ア、゙、サ、。ェ\n");
   while (($line = fgetss($fp, 1024, "<title><p>")))
   {
      if(!preg_match("/^\s+$/", $line))
      {
         print htmlspecialchars($line, ENT_NOQUOTES);
      }
   }
   fclose($fp);

   print "</pre>";
?>

<戻る

R HOUSE | RIKO's Trial Page | Shirley's Pettit Case | Shirley's i-box | Shirley's little box

Gポイントポイ活 Amazon Yahoo 楽天

無料ホームページ 楽天モバイル[UNLIMITが今なら1円] 海外格安航空券 海外旅行保険が無料!