note 54140 deleted from function.parse-ini-file by cmb
| From: | cmb@php.net | Date: | Sun, 15 Sep 2019 13:00:28 +0000 |
| Subject: | note 54140 deleted from function.parse-ini-file by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212187@lists.php.net to get a copy of this message | ||
Note Submitter: dreamscape
----
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