note 40338 deleted from function.file by bjori

From: Date: Wed, 22 Mar 2006 13:51:26 +0000
Subject: note 40338 deleted from function.file by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106258@lists.php.net to get a copy of this message
Note Submitter: http://iubito.free.fr ---- Another way to do mvanbeek at supporting-role dot co dot uk (31 december) config reader. I've an array $config <?php $array_tmp = file('configfile.txt'); foreach($array_tmp as $v) { if ((substr(trim($v),0,1)!=';') && (substr_count($v,'=')>=1)) {//Line mustn't start with a ';' and must contain at least one '=' symbol. $pos = strpos($v, '='); $config[trim(substr($v,0,$pos))] = trim(substr($v, $pos+1)); } } unset($array_tmp); ?> The configfile : variable = value will be loaded into $config['variable'] = 'value'; it trims spaces near the '=', don't read lines starting with a ';' (it can have spaces and tabs before the ';' ). Have a nice day :)

« previous php.notes (#106258) next »