Help with end of search with file_get

$file = "/var/www/html/sataxicrm/custom/include/language/lang.en_us.lists.txt";
$content = file_get_contents($file);
$pos = strpos($content,"account_type_dom");
$end = strpos($content,"industry_dom");
$string = substr($content,$pos,($end- $pos));
$array = nl2br($string);
//print $content;
echo "Database Value:Label Value <br>";
print $array;

The above code works well if you knowwhat your end string is, but in my case i do not know. i only know the start.
Below is an example of the text

As you can see i know it starts with account_type_dom but i do not know that it will end before industry_dom. so i need to stop before industry_dom. how do i do this?

account_type_dom
@clear
“”: “”
@orig Customer
"Brand Owner ": "Brand Owner "
Printing Company: Printing Company
Installation Company: Installation Company
Sales Person: Sales Person
Zebra: Zebra
industry_dom
@clear
“”: “”
@orig Apparel
@orig Banking
@orig Biotechnology
@orig Chemicals
@orig Communications

Would it be easier to read the file using file() and process each line as part of an array?

First you need to define in words exactly where your end-point is, rather than where it is not. For example, is it fair to say that after you have your account_type_dom, you’ll have two @clear lines, and you end two lines before the second one? Or does any line starting in @ suggest something special, and you can work backwards from that? Or how about any line ending in “_dom” as a marker? Or the first line that doesn’t include a : colon separator?

It’s a bit difficult to suggest options based only one record - what other things could be in that spot if industry_dom is not?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.