note 54140 added to function.parse-ini-file

From: Date: Fri, 24 Jun 2005 16:10:13 +0000
Subject: note 54140 added to function.parse-ini-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-90907@lists.php.net to get a copy of this message
I handy function to allow values with new lines if you are PHP4, is the following: <?php function prepareIniNl($string) { return preg_replace("/(\r\n|\n|\r)/", "\\n", $string); } ?> Now, when writing your INI file, parse the value through the function and it will turn for example: Value line 1 Value line 2 Into literally: Value line 1\nValue line 2 Which is stored as a single line in the INI file. And when you read the INI file back into PHP, the \n will be parsed and you're value will be back to: Value line 1 Value line 2 ---- Manual Page -- http://www.php.net/manual/en/function.parse-ini-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54140 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54140&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54140&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90907) next »