Welcome to WebmasterWorld Guest from 126.96.36.199
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.
, which will avoid creating extra <li>s when users put extra lines between items, as well as ignore any leading or trailing spaces on each line. (That trim() is for leading whitespace on the first line and trailing whitespace on the last.)
preg_split('/[ \t]*[\r\n]+[ \t]*/', trim($foo), -1, PREG_SPLIT_NO_EMPTY)
Of course, if all you want to do is cut out those trailing lines, eelixduppy's suggestion of rtrim() will probably work just dandy. :)