Fopen search text from to

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";
}

The code needed to find, sort, insert, update, delete, … and manage file locking so that data doesn’t get corrupted during concurrent accesses has already been written and tested. It’s called a database engine. There’s no good reason to write your own code to perform these actions on data in a text file.

well thats helpfull. So it means you dont know how to do this then? Why respond if you have no clue how to develop this

Sponsor our Newsletter | Privacy Policy | Terms of Service