直接读取,返回一维数组
- 如,"test.ini" 的内容:
[names]me = Robertyou = Peter [urls]first = "http://www.example.com"second = "http://www.w3school.com.cn"
- 代码:
<?php ?????print_r(parse_ini_file("test.ini"));?>
- 结果是:
Array([me] => Robert[you] => Peter[first] => http://www.example.com[second] => http://www.w3school.com.cn)
- 结果并不能准确的表达数据之间的关系
使用第二个参数,按多维数组返回结果
- 代码:
<?php ?????print_r(parse_ini_file("test.ini", true));//第二个参数表示process_sections?>
+结果:
Array([names] => Array ?( ?[me] => Robert ?[you] => Peter ?)[urls] => Array ?( ?[first] => http://www.example.com ?[second] => http://www.w3school.com.cn ?))
- 使用了第二个参数后,返回的结果是一个多维数组,数据的关系也还存在
PHP的parse_ini_file()函数,解释结构类型php.ini格式的文件
原文地址:https://www.cnblogs.com/jjxhp/p/9937673.html