File get help with end value

Good day all.

I am trying to get strings from txt file with a start and an end.

$file = "/var/www/html/sataxicrm/custom/include/language/lang.en_us.lists.php";
$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 know what 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?

So it will start at account_type_dom as that is what they request but the last entry must be " Zebra: Zebra"
as that is the last entry of account_type.

  Quote
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
<?php
$data = file('paulq.txt', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);

$start = "sales_probability_dom";

$results = [];

$pos = array_search($start, $data);              // find start key

while ($data[++$pos][0]=="\t") {                 // check for  tab at start of line
    $results[] = trim($data[$pos]);
}

echo '<pre>', print_r($results, 1), '</pre>'; 
?>
giving


Array
(
    [0] => @clear
    [1] => \"\": \"\"
    [2] => Closed Won: \"100\"
    [3] => Id. Decision Makers: \"40\"
    [4] => Needs Analysis: \"25\"
    [5] => Negotiation\/Review: \"80\"
    [6] => Perception Analasis: \"50\"
    [7] => Proposal\/Price Quote: \"65\"
    [8] => Prospecting: \"10\"
    [9] => Qualification: \"20\"
    [10] => Value Prospecting: \"30\"
)

Is the file the same format every time?

Sponsor our Newsletter | Privacy Policy | Terms of Service