Hi all.
I have a php file that i need to read contents from. I can search for a string but i am stumped on how to start from a point and to end at a point
Below is the payout of the file. I just want to return
Paul1
plist1: plist1
plist2: plist2
plist3: plist3
plist4: plist4
and not the rest.
file looks like
quote_lost_reason
“”: “”
Price: Price
Product: Product
Other: Other
Paul1
plist1: plist1
plist2: plist2
plist3: plist3
plist4: plist4
Site Lighting
Interior: Interior
Exterior: Exterior
credit
credit_note: Credit Note
where line entry ends with last tab entry
here is my code so far
$file = '/var/www/html/***/custom/include/language/lang.en_us.lists.php';
$searchfor = "Paul1";
$array = file($file);
//print_r($array);
header('Content-Type: text/plain');
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $contents, $matches)){
echo "Found matches:\n";
echo implode("\n", $matches[0]);
}
else{
echo "No matches found";
}