On Wed, 27 Mar 2002, James Taylor wrote: > Ok, let me try to refine this as the big picture. User enters something into > a form. > > We take that form value and convert newlines into <br /> though nl2br. > > Then, I want the limit the number of consecutive <br />'s a user can enter, > to avoid abuse via a person just holding down enter for a while. > > $message = nl2br($message); > $message = preg_replace("/\n/", "", $message); > > while (stristr($message, '<br /><br /><br />')) { > $message = str_replace('<br /><br /><br />', '<br /><br />', $message); > }
If you want to keep it to a maximum of, say, 2 <br /> tags, then why not just use something like: $message = preg_replace('/(<br />\w*){2,}/', '<br /><br />', nl2br($message)); miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php