note 22505 added to function.parse-ini-file
| From: | info at megaman dot nl | Date: | Thu, 20 Jun 2002 13:56:38 +0000 |
| Subject: | note 22505 added to function.parse-ini-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32043@lists.php.net to get a copy of this message | ||
Hi!
I've had the same problems with larger files, also some fields in the ini file were incorrectly
retrieved. I'm using the following bit of code now, does the trick for me...
while(!feof($fp)) {
$line = trim(fgets($fp, 1024));
if($line[0] == "[" && $line[strlen($line) - 1] == "]") {
$sec_name = substr($line, 1, strlen($line) - 2);
}
else {
$pos = strpos($line, "=");
$property = substr($line, 0, $pos);
$value = substr($line, $pos + 1, strlen($line) - $pos - 1);
$ini_array[$sec_name][$property] = $value;
}
}
--
http://www.php.net/manual/en/function.parse-ini-file.php
http://master.php.net/manage/user-notes.php?action=edit+22505
http://master.php.net/manage/user-notes.php?action=delete+22505
http://master.php.net/manage/user-notes.php?action=reject+22505