Reputation: 664
I am wanting to setup a script that fopen's or similar a remote php file with the output of say:
version= 1.1.0
date= 01/22/13
link= http://example.com/1.1.0
blah= blah
But I am wanting to remotely, turn this file into the corresponding variables in the local php script.
I have seen this done many of places, but can't seem to find a how-to on it!
Upvotes: 1
Views: 104
Reputation: 2784
you could make it into an ini file
[Current Release]
version=1.1.0
date="1/22/13"
Then in a file that will be requested by the server
$content = parse_ini_file('my_file.ini');
//JSON
echo json_encode($content);
Upvotes: 3
Reputation: 3707
"file" returns an array of lines. Explode these on the "=" and assign to a variable variable.
<?
$configLines = file('configfile.txt');
foreach ($configLines as $av)
{
list ($a, $v) = explode('=', $av);
$$a = $v;
}
?>
Upvotes: 2