Exemple #1
0
 /**
  * Read ini file and return values as array
  *
  * @param string $fileName The name of the ini file to read
  * @param string $section If the section name you want to get only certain sections
  * @return ArrayObject|array
  */
 public static function load($fileName, $section = null)
 {
     $ret = false;
     $path = PathManager::getConfigDirectory() . DIRECTORY_SEPARATOR . $fileName;
     if (file_exists($path)) {
         $iniArray = parse_ini_file($path, true);
         if ($section != null) {
             if (isset($iniArray[$section])) {
                 $iniArray = $iniArray[$section];
                 $ret = self::_levelize($iniArray);
             }
         } else {
             $ret = array();
             foreach ($iniArray as $sec => $values) {
                 $ret[$sec] = self::_levelize($values);
             }
         }
         if (is_array($ret) && self::$_isReturnObject == true) {
             $ret = self::_toArrayObject($ret);
         }
     }
     return $ret;
 }