Read a text file with PHP and display all text after a certain string?

$file = "file. Txt"; $f = fopen($file, 'rb'); $found = false; while ($line = fgets($f, 1000)) { if ($found) { echo $line; continue; } if (strpos($line, "ITEM DESCRIPTION:")! == FALSE) { $found = true; } }.

I get a empty screen – Alex Aug 8 at 19:30 Woops. Sorry. The strpos arguments are reversed.

I'll edit the answer. – Marc B Aug 8 at 19:32 ok I reversed the strpos arguments and it works now thanks – Alex Aug 8 at 19:32.

$contents = strstr(file_get_contents('file. Txt'), 'ITEM DESCRIPTION:'); # or if you don't want that string itself included: $s = "ITEM DESCRIPTION:"; # think of newlines as well "\n", "\r\n", .. or just use trim() $contents = substr(strstr(file_get_contents('file. Txt'), $s), strlen($s)).

What about $file = "file. Txt"; $f = fopen($file, "r"); $start = false; while ($line = fgets($f, 1000)) { if ($start) echo $line; if ($line == 'ITEM DESCRIPTION') $start = true; }?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions