Reputation: 6697
I've joined to a new team/project and there is a .ini
file in the project which is used as the project configuration file. The content of it looks like:
[version]
v = 1
[paths]
website = http://localhost
base_url = /myweb/
images_path = C:\\xampp\\htdocs\\myweb\\img\\
attached_file_path = C:\\xampp\\htdocs\\myweb\\attached_files\\
[limitation values]
max_avatar_size = 2 ; MB
max_uploaded_image_size = 3 ; MB
max_uploaded_file_size = 4 ; MB
I can access those values like this: config('item_name')
, i.e config('base_url')
which return /myweb/
. Noted that config()
function uses parse_ini_file()
function.
My question is, what are those section titles? i.e [version]
, [paths]
.. ? Are they accessible? If yes, how?
Upvotes: 0
Views: 206
Reputation: 19780
The function parse_ini_file()
have a second argument : bool process_sections
.
$ini_array = parse_ini_file("sample.ini", true); // true means "process_sections"
// var_dump(array_keys($ini_array)) ;
var_dump($ini_array['paths']['base_url']) ;
Upvotes: 2