On Aug 27, 8:31 am, innamorato.pa.. .@gmail.com wrote:
Hi!
I would like to create a php script that read a txt file and filter it
with 2 keywords, first keyword deifne the start and the second one the
end of the txt to read.
And then give the output extracted.
Expter of the group, could you help me?
thanks!
You might be looking for something like the following. I haven't
tested this, so I'm sure my string parsing is off by one, or
something. Also the variable names are kind of long for clarity's
sake; you may want to shorten them.
$file_path = "/path/to/file.txt";
$contents = file_get_conten ts($file_path);
$start_string_p osition = strpos($content s, "start");
$end_string_pos ition = strpos($content s, "end",
$start_string_p osition);
$extracted_stri ng_length = $end_string_pos ition -
$start_string_p osition;
$extracted_stri ng = substr($content s, $start_string_p osition,
$extracted_stri ng_length);