PHP的parse_ini_file()函数,解释结构类型php.ini格式的文件

时间:2018-11-10 00:00:54   收藏:0   阅读:188

直接读取,返回一维数组

[names]
me = Robert
you = 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
  )
)

原文:https://www.cnblogs.com/jjxhp/p/9937673.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!