开发者

PHP read, stored php var in text file

开发者 https://www.devze.com 2023-04-08 07:34 出处:网络
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_g

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()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号