php ini class cannot see whats going wrong -


im trying create php class transform ini in array ie:

example.ini...

[helloworld] testing=1234 

the array should like:

array {     "helloworld" = array {         "testing" = "1234"     } } 

my code fo far this:

<?php     require_once "usefullfunctions.inc.php";      class ini {         protected $keys = array();         protected $values = array();          public function __construct($filename) {             if (!file_exists($filename)){                 throwexception('file not found',$filename);             }             $file = fopen($filename, 'r');             $isin = "";             while (($line = fgets($file)) !== false) {                 if(!startswith($line,'#')){  // checks if line comment                     if(startswith($line,'[')){                         $isin = trim($line,'[]');                         $this->keys[$isin] = '';                         $this->values[$isin] = array();                     } else {                         if ($isin != ""){                             $vars = explode("=",$line);                             $this->values[$isin][$vars[0]] = $vars[1];                         }                     }                 }             }             var_dump($this->values);             if (!feof($file)) {                 echo "error: unexpected fgets() fail\n";             }             fclose($file);         }         public function getvalues() {             return $this->values;         }     } ?> 

the other functions(starts with, throwexception) ive tested , work fine still returns blank array think stuffing after checks if line comment doesnt come error messages cant sure

just incase here starts code:

function throwexception($message = null,$code = null) {     throw new exception($message,$code); }  function startswith($haystack, $needle) {     return !strncmp($haystack, $needle, strlen($needle)); } 

take @ parse_ini_file

http://uk3.php.net/parse_ini_file


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -