note 54737 modified in function.parse-ini-file by danbrown

From: Date: Sun, 23 Jan 2011 17:14:12 +0000
Subject: note 54737 modified in function.parse-ini-file by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176168@lists.php.net to get a copy of this message
Class to access ini values at format "section_name.property", for example $myconf->get("system.name") returns a property "name" in section "system": <?php class Settings { var $properties = array(); function Settings() { $this->properties = parse_ini_file(_SETTINGS_FILE, true); } function get($name) { if(strpos($name, ".")) { list($section_name, $property) = explode(".", $name); $section =& $this->properties[$section_name]; $name = $property; } else { $section =& $properties; } if(is_array($section) && isset($section[$name])) { return $section[$name]; } return false; } } ?> --was-- Class to access ini values at format "section_name.property", for example $myconf->get("system.name") returns a property "name" in section "system": class Settings { var $properties = array(); function Settings() { $this->properties = parse_ini_file(_SETTINGS_FILE, true); } function get($name) { if(strpos($name, ".")) { list($section_name, $property) = explode(".", $name); $section =& $this->properties[$section_name]; $name = $property; } else { $section =& $properties; } if(is_array($section) && isset($section[$name])) { return $section[$name]; } return false; } } http://php.net/manual/en/function.parse-ini-file.php

« previous php.notes (#176168) next »