PHP - Stop searching when match is found

licocoxyni

New Member
Incoming is a single word from a text box or another function\[code\]function searchformatch($keyword){ if(!$keyword){hey-enter-a-keyword-function();} foreach (glob("directory/*.txt") as $filename) { $file = $filename; $contents = file($file); $string = implode($contents); foreach ($string as $look){ if (preg_match("/\b".$keyword."\b/i", $look) { /*echo $string;*/ } } } }\[/code\]This is my attempt to try to look for an exact line match in some files in a directory. (each line is one word.)But, I want it to stop searching when a match is found.I also want to do this in another function if $keyword is an array of keywords. (eg: in from a text area.) But, that is probably another question.
 
Back
Top