Parse a string in ii:
$ini = ‘ [names] me = “Robert” you = “Peter” [urls] first = “http://www.example.com” second = “https://www.w3schools.com” ‘; print_r(parse_ini_string($ini)); |
The following is the result of the code above:
Array ( [names] => Array ( [me] => Robert [you] => Peter ) [urls] => Array ( [first] => http://www.example.com [second] => https://www.w3schools.com ) ) |
An configuration (ini) string is parsed by the parse_ini_file() method, which then returns the settings.
Advice: This function is unrelated to the php.ini file and can be used to read in your own configuration files.
Note: The following reserved words—null, yes, no, true, false, on, off, and none—must not be used as keys for ini files. Moreover, the key cannot contain any of the reserved letters {}|&~!()^”.
parse_ini_string(ini, process_sections, scanner_mode) |
Parameter |
Description |
ini |
Essential. indicates which ini file to parse. |
process_sections |
Not required. It returns a multidimensional array containing section names and settings if set to TRUE. False is the default. |
scanner_mode |
Not required. may take on any of the subsequent values: INI_SCANNER_TYPED denotes the preservation of integer, null, and boolean types whenever it is feasible. “Yes”, “on”, and “true” are changed to TRUE. “Off”, “no”, “false”, and “none” are changed to FALSE. NULL is created from “null”. If at all possible, numerical strings are transformed to integer type. |
Return Value: |
False on failure, array on success |
PHP Version: |
5.3+ |