note 93732 deleted from function.parse-ini-string by danbrown

From: Date: Fri, 25 Sep 2009 17:12:36 +0000
Subject: note 93732 deleted from function.parse-ini-string by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161065@lists.php.net to get a copy of this message
Note Submitter: mufumbo at hotmail dot com ---- I've written this article: mufumbo.wordpress.com /2009/08/05/reading-java-style-properties-file-in-php/ The following function parse a java-like Properties. function parse_properties($txtProperties) { $result = array(); $lines = split("\n", $txtProperties); $key = ""; $isWaitingOtherLine = false; foreach ($lines as $i => $line) { if (empty($line) || (!$isWaitingOtherLine && strpos($line, "#") === 0)) continue; if (!$isWaitingOtherLine) { $key = substr($line, 0, strpos($line, '=')); $value = substr($line, strpos($line, '=')+1, strlen($line)); } else { $value .= $line; } if (StrUtil::endsWith($value, "\\")) { $value = substr($value,0,strlen($value)-1)."\n"; $isWaitingOtherLine = true; } else { $isWaitingOtherLine = false; } $result[$key] = $value; unset($lines[$i]); } return $result; }

« previous php.notes (#161065) next »