Thurrock Posted February 13, 2013 Share Posted February 13, 2013 Hi, I am banging my head against the wall here trying to get this to work, I need to read each line of a txt file and then match lines containing one or two word keywords, this script matches letters but I seem to be running into a wall here trying to get it to work, my guess it is a simple solution? $lines = file('uploads/file.txt'); foreach ($lines as $line_num => $line) { $line = strtolower($line); if(preg_match("/version/i", "$line")){ echo "<span style=\"color:#cccccc;\">Line #<strong>{$line_num}</strong> : " . $line . "</span><br />\n"; } else { echo "Line #<strong>{$line_num}</strong> : " . $line . "<br />\n"; } } Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/274438-matching-lines-containing-words-from-txt-file/ Share on other sites More sharing options...
Thurrock Posted February 13, 2013 Author Share Posted February 13, 2013 Resolved: There was html tags near the keyword I was searching for, resolved with strip_tags(); Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/274438-matching-lines-containing-words-from-txt-file/#findComment-1412209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.