note 93732 added to function.parse-ini-string

From: Date: Thu, 24 Sep 2009 21:53:42 +0000
Subject: note 93732 added to function.parse-ini-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-161035@lists.php.net to get a copy of this message
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; } ---- Server IP: 208.69.120.35 Probable Submitter: 71.6.82.200 ---- Manual Page -- http://www.php.net/manual/en/function.parse-ini-string.php Edit -- https://master.php.net/note/edit/93732 Del: integrated -- https://master.php.net/note/delete/93732/integrated Del: useless -- https://master.php.net/note/delete/93732/useless Del: bad code -- https://master.php.net/note/delete/93732/bad+code Del: spam -- https://master.php.net/note/delete/93732/spam Del: non-english -- https://master.php.net/note/delete/93732/non-english Del: in docs -- https://master.php.net/note/delete/93732/in+docs Del: other reasons-- https://master.php.net/note/delete/93732 Reject -- https://master.php.net/note/reject/93732 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161035) next »