Thursday, 27 November 2014

parse_ini_string - Parse a configuration string

array parse_ini_string ( string $ini [, bool $process_sections = false [, int $scanner_mode = INI_SCANNER_NORMAL ]] )
Parse a configuration string
parse_ini_string returns the settings in string ini in an associative array.

Function parse_ini_file doesn't parse a remote ini file if allow_url_include is off. But if allow_url_fopen is on, you can use parse_ini_string to parse a remote ini file after read its contents.
/**
* Assume that; allow_url_include=0 and allow_url_fopen=1
* (default values in php.ini)
*/

$iniUrl = 'http://website.com/remote/config.ini';
/**
* Warning: parse_ini_file(): http:// wrapper is disabled in the server configuration by allow_url_include=0
*/
$config = parse_ini_file($iniUrl);

/**
* works fine
*/
$config = parse_ini_string(file_get_contents($iniUrl));