我有这样的搜索脚本中筛选出特定的字符串:一个txt文件
$search = $_GET["search"];
$logfile = $_GET['logfile'];
$file = fopen($logfile, "r");
?>
<head>
<title>Searching: <?php echo $search ?></title>
</head>
<?php
while(($line = fgets($file))!= false) {
if(stristr($line,$search)) {
// case insensitive
echo "<font face='Arial'> $line </font><hr><p>";
}
}
我想筛选出特定字符串为txt文件的东西搜索时。
例如,文本文件包含此:
http://test.com/?id=2022458&pid=41&user=Ser_Manji
Ser_manji said "hello"
Ser_manju left the game
当您搜索例如用于“Ser_manji”,我想筛选出这串:
http://test.com/?id=2022458&pid=41&user=Ser_Manji
但仍显示这些两行:
Ser_manji said "hello"
Ser_manju left the game
我希望这是可能的,我自己tryied改变它,所以它不会接受与包含“test.com”的行有关,但没有奏效。
仅供参考:您可以接受最能帮助您的答案并解决您的问题(http://meta.stackexchange.com/q/5234)! – Rizier123