Location: PHPKode > scripts > INI File Parser > ini-file-parser/parseini.class.php
<?php

/**
 * Code written by Roy Cunningham - March 17, 2008 (rc<numberone> at hesperides dot ca)
 * This is licensed under the GPL - feel free to use and redistribute, but keep this license disclaimer intact.
 * Have fun!
 */

class parseini {
	
	private $result = array();

	public function parse($file){
		if ($lines = file($file)) {
			$ini_key=array();
			foreach ($lines as $l){
				if (!preg_match('/[0-9a-z]/i', $l) or preg_match('/^#/', $l)){
					continue;
				}
				if (preg_match('/(\[)(.*)(\])/i', $l)){
				} else {
					preg_match('/(.*)=(.*)/', $l, $t);
					$result[$ini_key[2]][$t[1]]=rtrim($t[2],"\r\n");
					}
				}	
		} else {
			die("No valid file specified");
		}
		return $result;
	}
}

?>
Return current item: INI File Parser