RE: [PHP] parse_ini_file + newlines
| From: | John W. Holmes | Date: | Sat, 19 Apr 2003 15:08:54 +0000 |
| Subject: | RE: [PHP] parse_ini_file + newlines | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144480@lists.php.net to get a copy of this message | ||
How is this supposed to be "better"? Does it account for lines that are
comments?
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
> -----Original Message-----
> From: Dan Rossi [mailto:daniel@electroteque.org]
> Sent: Saturday, April 19, 2003 8:47 AM
> To: Dan Rossi; php-general@lists.php.net
> Subject: RE: [PHP] parse_ini_file + newlines
>
> hmm following a custom example on the manual page
>
> i managed to edit it slightly to join the current line to the previous
> array
> and add a newline between them
>
> function better_parse_ini_file($filename, $process_sections = false) {
> $ini_array = array();
> $sec_name = "";
> $lines = file($filename);
> //print_r($lines);
> foreach($lines as $line) {
> $line = trim($line);
>
> if($line == "") {
> continue;
> }
>
> if($line[0] == "[" && $line[strlen($line) - 1] == "]") {
> $sec_name = substr($line, 1, strlen($line) - 2);
> //die($sec_name);
> } else {
> if ($pos = strpos($line, "=")) {
> $property = substr($line, 0, $pos);
> $value = substr($line, $pos + 1);
> if($process_sections) {
> $ini_array[$sec_name][$property] = $value;
> } else {
> $ini_array[$property] = $value;
> }
> } else {
> end($ini_array);
> $key = key($ini_array);
> $ini_array[$key] .= " \n".$line;
> }
> }
> }
>
> return $ini_array;
> }
>
> -----Original Message-----
> From: Dan Rossi [mailto:daniel@electroteque.org]
> Sent: Saturday, April 19, 2003 8:56 PM
> To: php-general@lists.php.net
> Subject: [PHP] parse_ini_file + newlines
>
>
> hi there parse_ini_file seems to break if i manage the ini file via a
form
> and have newlines in the file , it is breaking what can i do , i
> particularly need newlines for email messages, let me know thanks
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php