parse_ini_string
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
parse_ini_string — Parse a configuration string
Description
$ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|falseparse_ini_string() returns the settings in string ini_string in an associative array.
The structure of the ini string is the same as the php.ini's.
This function must not be used with untrusted inputs, unless scanner_mode is INI_SCANNER_RAW since the parsed output might contain the values of sensitive constants, such as constants holding a database password.
Parameters
ini_stringThe contents of the ini file being parsed.
process_sectionsBy setting the
process_sectionsparameter totrue, you get a multidimensional array, with the section names and settings included. The default forprocess_sectionsisfalsescanner_modeCan either be
INI_SCANNER_NORMAL(default) orINI_SCANNER_RAW. IfINI_SCANNER_RAWis supplied, then option values will not be parsed.As of PHP 5.6.1 can also be specified as
INI_SCANNER_TYPED. In this mode boolean, null and integer types are preserved when possible. String values"true","on"and"yes"are converted totrue."false","off","no"and"none"are consideredfalse."null"is converted tonullin typed mode. Also, all numeric strings are converted to integer type if it is possible.
Notes
Note: There are reserved words which must not be used as keys for ini files. These include:
null,yes,no,true,false,on,off,none. Valuesnull,off,noandfalseresult in"", and valueson,yesandtrueresult in"1", unlessINI_SCANNER_TYPEDmode is used. Characters?{}|&~![()^"must not be used anywhere in the key and have a special meaning in the value.
See Also
- parse_ini_file() - Parse a configuration file