note 27920 modified in function.wordwrap by danbrown

From: Date: Sun, 17 May 2009 18:38:10 +0000
Subject: note 27920 modified in function.wordwrap by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155153@lists.php.net to get a copy of this message
Here's some code which will turn text into a quoted message, that is, split a chunk of text into wrapped lines and prefix each line of text with a > sign (or some other delimiter). I found myself using this snippet so many times while writing an autoresponder that I just dropped it into a function. <?php function mailquote($text, $marker){ $text = str_replace("\n", "\n$marker", wordwrap($text, 70)); return $text; } ?> e.g. mailquote($text, "> "); > Would result in a long passage of text > being broken into multiple lines, each > line starting with a traditional "quote" > marker, like this. --was-- Here's some code which will turn text into a quoted message, that is, split a chunk of text into wrapped lines and prefix each line of text with a > sign (or some other delimiter). I found myself using this snippet so many times while writing an autoresponder that I just dropped it into a function. function mailquote($text, $marker){ $text = str_replace("\n", "\n$marker", wordwrap($text, 70)); return $text; } e.g. mailquote($text, "> "); > Would result in a long passage of text > being broken into multiple lines, each > line starting with a traditional "quote" > marker, like this. http://php.net/manual/en/function.wordwrap.php

« previous php.notes (#155153) next »