With function parse_ini_stringM() below you can:
- fix unvalued fields ('key' (invalid) ==> 'key=' (OK) )
- fix unquotted values with equal sign '=' ('key=value_part1=value_part2' ==> 'key="value_part1=value_part2"')
- fix (solve) multidimensional arrays (makes 'key[key1][key2]=value' valid)
function parse_ini_stringM() on github https://gist.github.com/msegu/c43a871c5a874a1d9bff978b448a0aa4 (here is too long)
// Example:
$ini = '[a]
b
c=d
e=';
var_export(parse_ini_string($ini, TRUE)); /* array (
'a' =>
array (
'c' => 'd',
'e' => '',
),
)
*/
$ini .= '
f[g][2]=h
f[g][i]=j
f[g][][]=k
m=n=o';
var_export(parse_ini_string($ini, TRUE)); // false
var_export(parse_ini_stringM($ini, TRUE)); /* array (
'a' =>
array (
'b' => '',
'c' => 'd',
'e' => '',
'f' =>
array (
'g' =>
array (
2 => 'h',
'i' => 'j',
3 =>
array (
0 => 'k',
),
),
),
'm' => 'n=o',
),
)
*/