note 40485 deleted from function.parse-ini-file by nlopess
| From: | nlopess@php.net | Date: | Fri, 05 Mar 2004 18:05:14 +0000 |
| Subject: | note 40485 deleted from function.parse-ini-file by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66315@lists.php.net to get a copy of this message | ||
Note Submitter: hackajar matt yahoo trot com
----
So what if you cannot load ini support? Say in a shared server environment?
Code snip!--------->
if(file_exists("./trace.ini")) {
$fp = fopen("./trace.ini", "r+");
$string = fread($fp, filesize("./trace.ini"));
$array = explode("\r\n", $string);
foreach($array as $line) {
switch(substr($line, 0, 1)) {
case "[": $main = ltrim(rtrim($line, "]"), "[");
$tmp_array[$main]; break;
case ";": //do something clever here; break;
default:
//Removes that whitespace before and after the = in you ini file
$line = str_replace(" ", "", $line);
$tmp_array[$main] = explode("=", $line);
$o = 0;
foreach($tmp_array as $val) {
if($o == 0) {
$rkey = $val;
$o++;
} else {
$buf[$main][$rkey]=$val;
$o = 0;
}
}
break;
}
}
}
<------Code Snip!