I have a piece of php code that upon a page load request finds a corresponding file which contains information about the page including the password.
The syntax in the file is as follows:
Pagename:
PageInfo:
Password: SecretPassword
How would I get around finding the password following the Password:?
My PHP code looks like this:
$filepath = absolute_url("page/info.php");
$infoFile = fopen("$filepath", "r");
$contents = stream_get_contents($infoFile);
Seems a very strange way to store the data. Assuming this can't be helped though, you could RegEx this with something like:
$matches = array();
preg_match('/Password:\s(.*)$/', $contents, $matches);
// ^ Assuming there's only ever 1 space
echo $matches[1]
will print SecretPassword