A class to parse config files.
<?php class config { public static $cfg = array(); public static $pkg = array(); function __construct() { config::build_cfg(); } public function build_cfg() { # Get Config File $handle = file_get_contents('./conf.inc.php'); # Explode Array $array = explode("\n", $handle); # Loop Through Array foreach($array as $row) { # Explode Row $var = explode("^", $row); # Set Config Values config::$cfg[$var[0]] = $var[1]; } } public function print_cfg() { print_r(config::$cfg); } } ?>
conf.inc.php syntax is as follows.
site_path^/home/example
site_url^http://example.co.uk
theme^default
Array is stored in config::$cfg.
Comments
Add your comment