08/01/31 14:37:56
文字列検索プログラムを書いたぞ。phpだけど。
このファイルと同じディレクトリに[in.txt]という名前で文書ファイルがあるものとする。
<html><body>
<form method="POST" action="test.php"><input type="text" name="key" size=30>
<input type="submit" value="送信"></form>
<hr>
<?php
if($_POST["key"] == ""){
echo "</body></html>";
exit;
};
$key = $HTTP_POST_VARS["key"];
echo "検索キー:$key<br>";
// 検索キーを空白スペースで分割する。
$key2 = split(" ", $key);
// 要素数を出す。
$key2_cnt = count($key2);
$INFILE = fopen("in.txt","r");
$line_num = 1;
$cnt = 0;