note 40926 deleted from function.parse-ini-file by danbrown

From: Date: Sun, 23 Jan 2011 17:17:41 +0000
Subject: note 40926 deleted from function.parse-ini-file by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176181@lists.php.net to get a copy of this message
Note Submitter: LIU student ---- [Editor's note: The fwrite()-line should look like: "if (fwrite($handle, $content) === false) {" to avoid returning false when the array is empty --victor@php.net] function writeIni($assoc_arr, $path){ $content = ""; foreach ( $assoc_arr as $key=>$elem ){ $content .= "[".$key."]\n"; foreach ( $elem as $key2=>$elem2){ $content .= $key2." = \"".$elem2."\"\n"; } } if (!$handle = fopen($path, 'w')) { return false; } if (!fwrite($handle, $content)) { return false; } fclose($handle); return true; }

« previous php.notes (#176181) next »