I would like to read text file in PHP which break or exit after match condition.
PHP CODE:
$file = fopen("testFile.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
{
$line = fgets($file, 1024);
if($line=="NOTE"){
break;
}
echo $line ."<br>";
}
fclose($file);
Example
line1: i love u so much
line2: this is tom
Line3: note
Line: this is jam
Result need :
when meet note will be break.
line1: i love u so much
line2: this is tom
From what I gather you can have different cases, and like mario said you also have endlines. You should check like this: