Hi all,
I have a question regarding a search in a local file for lines with one search criterion.
Currently the process stops once the line with the search criterion is found the first time.
I want it working with one search criterion finding multiple lines till the end of the file and giving all those lines back.
The local file: (test.txt)(Sample)
Richard says Hello
Lisa says Hi
Peter says Good Morning
Richard says Bye
Sarah says Hello
[php]<?php
$search = “Richard”;
$tmp = ‘’;
$buffer = ‘’;
$fileaddress = ‘./test.txt’;
$file_handle = fopen($fileaddress, ‘r’);
for($i=1; !feof($file_handle); $i++){
$tmp = $buffer;
$buffer = fgets($file_handle, 16384);
if(strpos($tmp . $buffer, $search) !== false){
echo $buffer;
break;
}
}
fclose($file_handle);
?>[/php]
Thank you for your help.
Peter