Мне нужно создать сайт с помощью php, который может искать слово и возвращать строку, содержащую слово из 3 введенного текста, который был исправлен. Я могу найти слово и проверить, существует ли он внутри входного текста. Как я могу найти и вернуть результат в строку, содержащую словоСтрока поиска и строка возврата, содержащая строку
вот некоторые данные из входного файла
<paragraph><Date><Date>TUESDAY</Date></Date>. <Date>MARCH 3, 1903</Date>
Outstation Prosperity.
</paragraph>
<paragraph>THE perusal of the various Annual Reports from Outstations is interesting: and very minutely shows the work of the Country.
</paragraph>
здесь мои кодирования, что я сделал
<?php
$path = 'D:\Collective Intelligence\assignment&project\PROJECT-DATASET';
$findThisString = $_POST['search1'];
$dir = dir($path);
// Get next file/dir name in directory
while (false !== ($file = $dir->read()))
{
if ($file != '.' && $file != '..')
{
// Is this entry a file or directory?
if (is_file($path . '/' . $file))
{
// Its a file, yay! Lets get the file's contents
$data = file_get_contents($path . '/' . $file);
// Is the str in the data (case-insensitive search)
if (stripos($data, $findThisString) !== false)
{
// sw00t! we have a match
echo 'match found in ' . $file . "<br>\n";
}
}
}
}
$dir->close();
?>
спасибо, что вы лучший! =) – user2947488
@ user2947488 уверен, что это помогло – Ghost