hi,
I got the following code for you, and I"ll explain it below and what you were doing wrong:
foreach ($_POST as $key => $value) {
$$key = trim($value);
$$key = str_replace(array("\\\n", "\\\r\\\n", "\\\r"), "<br />", $$key);
$$key = stripslashes($$key);
$$key = rawurlencode($$key);
}
and it works. the only thing is that the rawurlencode encodes the <br> and makes it %br% (I don't know the exact numbers). I tested it out myself by adding: echo "this is ".$$key."<br />\n";
here's what youwere doing wrong.
first: as someone else said, each line would overwrite the previous one, but now: $$key has a value, and is now a variable with a value of that value. but you want to change that value with rawurlencode, and some other things, so the first thing you did was to trim it of any whitespace. but then, you stripped it of slashes, and that took the place of the previous value, instead of continuing to change the value. so you had to change $$key = stripslashes($value) to $$key = stripslashes($$key) to continue changing the same value. next, you wanted to replace all \r\n's with <br>, and the same for \n and \r alone. but the problem is, there are no more \n and \r once you do stripslashes, so we had to change those two functions around. I replaced your ereg_replace with str_replace because I hate ereg_replace because it confuses me, but we can do the same with an array in str_replace. then you run urlencode on $$key and it change all special characters to a %** symbol. then you have your result.
oh, and, I forgot...you had \n and \r. to replace them I changed them to \n and \r because they would then appear as \n and \r because of escaping and all that.
Brandon