RE: [PHP] parse_ini_file + newlines

From: Date: Sat, 19 Apr 2003 12:47:08 +0000
Subject: RE: [PHP] parse_ini_file + newlines
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144474@lists.php.net to get a copy of this message
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

« previous php.general (#144474) next »