PHP在子文件夹上的多个文件上搜索字符串

时间:2018-01-27 17:51:22

标签: php

您好我正试图通过翻找文件中已找到的内容进行搜索

这里我的代码听起来很有效

<?php
$search = $_POST['search'];
$dir = '/lol/';
$files = scandir($dir,1);
foreach ($files as $lines){
    foreach($lines as $line)
    {
    if(strpos($line, $search) !== false)
    echo $line;
    }
}
?>
</center>
  </div>
</div>
        <h3>Search by full email address or username. Example: user@test.com, usertest</h3>
<form action="a.php" method="post">
  <input type="text" name="search" />
  <input type="submit" value="Search" />
</form>        <p>
        </body>
</html>

0 个答案:

没有答案