note 96232 added to function.parse-ini-string

From: Date: Tue, 16 Feb 2010 11:16:26 +0000
Subject: note 96232 added to function.parse-ini-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-166003@lists.php.net to get a copy of this message
Thanks for the script below. Added some additional functionality for rows without any params such us: [example : something] if(!function_exists('parse_ini_string')){ function parse_ini_string($str, $ProcessSections=false){ $lines = explode("\n", $str); $return = array(); $inSect = false; foreach($lines as $line){ $line = trim($line); if(!$line || $line[0] == "#" || $line[0] == ";") continue; if($line[0] == "[" && $endIdx = strpos($line, "]")){ $inSect = substr($line, 1, $endIdx-1); if($ProcessSections && !isset($return[$inSect])) $return[$inSect] = array(); continue; } if(!strpos($line, '=')) // (We don't use "=== false" because value 0 is not valid as well) continue; $tmp = explode("=", $line, 2); if($ProcessSections && $inSect) $return[$inSect][trim($tmp[0])] = trim($tmp[1], " \t\"\'"); else $return[trim($tmp[0])] = trim($tmp[1], " \t\"\'");; } return $return; } } ---- Server IP: 69.147.83.197 Probable Submitter: 81.218.143.240 ---- Manual Page -- http://www.php.net/manual/en/function.parse-ini-string.php Edit -- https://master.php.net/note/edit/96232 Del: integrated -- https://master.php.net/note/delete/96232/integrated Del: useless -- https://master.php.net/note/delete/96232/useless Del: bad code -- https://master.php.net/note/delete/96232/bad+code Del: spam -- https://master.php.net/note/delete/96232/spam Del: non-english -- https://master.php.net/note/delete/96232/non-english Del: in docs -- https://master.php.net/note/delete/96232/in+docs Del: other reasons-- https://master.php.net/note/delete/96232 Reject -- https://master.php.net/note/reject/96232 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166003) next »