PHP read, stored php var in text file
I'm trying to figure out how 开发者_如何学Goto stored php values in a string/file. I have a text file with "var1=foo&var2=foo2" etc in it, is there a way to read the values?
You could use file_get_contents()
to open the file and parse_url()
to parse the contents into an associative array.
$file = file_get_contents('file.txt');
parse_str($file, $params);
CodePad.
Or if you can change it, theres always serialize()
and unserialize()
精彩评论