Find the string and then the line number using php from text file
Find the string and then the line number using php from text file
Find the string and then the line number using php from text file or a text data base.
In this we are searching a string named alan inside one of our log files.
$searchString = 'alan'; $URL = "logs/logs.txt_2011-08-10"; $data = file_get_contents($URL); $data = explode("\n", $data); for ($line = 0; $line < count($data); $line++) { if (strpos($data[$line],$searchString) != 0) { echo "String found on line ".++$line." with string $searchString<br>"; --$line; } }Find the string and then the line number using php from text file,