Is it possible to create an array with a settings file?
In the index.php
file there it reads .ini
file:
// Parse config file
$settings = parse_ini_file("settings");
E.g. Settings file looks like this:
[States]
east = "Michigan, New York, Minnesota"
Looking to create an array like so:
array('Michigan', 'New York', 'Minnesota')
The right way to create an array in your ini file is with brackets:
[States]
east[] = Michigan
east[] = New York
east[] = Minnesota
You can see an example in the documentation for parse_ini_file()
:
It returns an associative array. Then, to parse the east states into an array, you could do:
$eastStates = explode(', ', $ini['States']['east']);
if your data is indeed in the format you described. Note that you can create true arrays in ini format, see the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With