Re: Working with a config file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 20, 2006, at 2:21 PM, Benjamin Adams wrote:
I want to parse this so I can only call frank or freds data and move id, section, years, etc to varaibles.
Can someone give me some help

Here is a function I wrote, I bet it will help you (sorry, not the most readable because I pulled from bigger application I wrote, hopefully you can translate to suit your needs):

#### $ini = File to parse. e.g.[ 'rand_01.ini' ]
#### You might want to change extension of your config to ".ini", not sure if that will matter. $images = get_ini_file($ini); // Call $get_ini_file() function, put in $images array.

///////////////////////////////////////// function get_ini_file():
///////////////////////////////////////// Reads ini file for other functions:
function get_ini_file($ini) {
	global $PATH_TO_INI, $DEFAULT_INI_FILE;
	# if no custom ini file has been specified, use the default:
	$ini_file = $ini ? $PATH_TO_INI.$ini : $PATH_TO_INI.$DEFAULT_INI_FILE;
	# read the config file into an array or die trying:
	$parsed_ini = @parse_ini_file($ini_file, true);
	if(!$parsed_ini) {
		die('[ Unable to read ini file! ]');
	} else { return $parsed_ini; }
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux