Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Preg Replace newlines


alphacooler - 12:38 am on Jul 27, 2006 (gmt 0)


I have a form box where users enter in directions (one per line). I then turn each line into a list item <li>. The problem is that when people enter a blank line at the end it creates a new list item.

So I tried the following preg_replace to strip out extra lines at the end of the string. It doesn't work.

$directions = preg_replace('/\r+$/','',$_POST['directions']);

I also tried \n instead of \r.


Thread source:: http://www.webmasterworld.com/php/3023398.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com