public static function ini(string $ini_file, $environment = null) : array {
		$result = [];
		$data = parse_ini_file($ini_file, true);
		// processing environment
		if (!empty($data['environment'])) {
			foreach ($data['environment'] as $k => $v) {
				array_key_set($result, explode('.', $k), $v);
			}
		}
		unset($data['environment']);
		// small chicken and egg problem for environment variable
		if ($environment == null && !empty($result['environment'])) {
			$environment = $result['environment'];
		}
		// processing dependencies first
		if (!empty($data['dependencies'])) {
			foreach ($data['dependencies'] as $k => $v) {
				array_key_set($result, $k, $v);
			}
		}
		unset($data['dependencies']);
		// proccesing environment specific sectings
		foreach ($data as $section => $values) {
			$sections = explode(',', $section);
			if (empty($values) || (!in_array($environment, $sections) && !in_array('*', $sections))) continue;
			foreach ($values as $k=>$v) {
				array_key_set($result, $k, $v);
			}
		}
		return $result;
	}
public static function ini(string $ini_file, $environment = null) : array {
		$result = [];
		$data = parse_ini_file($ini_file, true);
		// processing environment
		if (!empty($data['environment'])) {
			foreach ($data['environment'] as $k => $v) {
				array_key_set($result, explode('.', $k), $v);
			}
		}
		unset($data['environment']);
		// small chicken and egg problem for environment variable
		if ($environment == null && !empty($result['environment'])) {
			$environment = $result['environment'];
		}
		// processing dependencies first
		if (!empty($data['dependencies'])) {
			foreach ($data['dependencies'] as $k => $v) {
				array_key_set($result, $k, $v);
			}
		}
		unset($data['dependencies']);
		// proccesing environment specific sectings
		foreach ($data as $section => $values) {
			$sections = explode(',', $section);
			if (empty($values) || (!in_array($environment, $sections) && !in_array('*', $sections))) continue;
			foreach ($values as $k=>$v) {
				array_key_set($result, $k, $v);
			}
		}
		return $result;
	}
public static function ini ( string $ ini_file , $ environment = null ) : array { $ result = [ ] ; $ data = parse_ini_file ( $ ini_file , true ) ; // processing environment if ( ! empty ( $ data [ 'environment' ] ) ) { foreach ( $ data [ 'environment' ] as $ k => $ v ) { array_key_set ( $ result , explode ( '.' , $ k ) , $ v ) ; } } unset ( $ data [ 'environment' ] ) ; // small chicken and egg problem for environment variable if ( $ environment == null && ! empty ( $ result [ 'environment' ] ) ) { $ environment = $ result [ 'environment' ] ; } // processing dependencies first if ( ! empty ( $ data [ 'dependencies' ] ) ) { foreach ( $ data [ 'dependencies' ] as $ k => $ v ) { array_key_set ( $ result , $ k , $ v ) ; } } unset ( $ data [ 'dependencies' ] ) ; // proccesing environment specific sectings foreach ( $ data as $ section => $ values ) { $ sections = explode ( ',' , $ section ) ; if ( empty ( $ values ) || ( ! in_array ( $ environment , $ sections ) && ! in_array ( '*' , $ sections ) ) ) continue ; foreach ( $ values as $ k => $ v ) { array_key_set ( $ result , $ k , $ v ) ; } } return $ result ; }
Process ini file

@param string $ini_file
@param string $environment
@return array
Process ini file