note 20740 added to function.preg-replace

From: Date: Sun, 14 Apr 2002 22:48:04 +0000
Subject: note 20740 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-29345@lists.php.net to get a copy of this message
This function takes plaintext files, seperated by carriage returns and turns it into HTML. In the process it also makes anything in "quotations" bold and anything in (brackets) italic. function fixup( $input ) { $lines=preg_split("/\n/", $input); $patterns = array( "/\"([`´\d\w,\s\.\?'!;:-]+)\"/", "/\(([`´\d\w,\s\.\?'!;:-]+)\)/"); $replace = array( "\"<span class=\"quotes\">\\1</span>\"", "(<span class=\"brackets\">\\1</span>)" ); foreach ($lines as $line_no=>$line) { $new_lines[$line_no] = "<p>".preg_replace($patterns, $replace, stripslashes($line))."</p>"; } $output=implode("\n",$new_lines); return $output; } -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+20740 http://master.php.net/manage/user-notes.php?action=delete+20740 http://master.php.net/manage/user-notes.php?action=reject+20740

« previous php.notes (#29345) next »