|
Posted by JackM on 11/01/05 04:29
JackM wrote:
> I'm trying to write a function that will trim and strip new line
> character returns from submitted $_POST values. Does this look serviceable?
>
> function trim_data($formdata)
> {
> foreach ($formdata as $key => $value)
> {
> $value = preg_replace("(\r\n|\n|\r|\t)", "", $value);
> $newdata[trim($key)] = trim($value);
>
> }
> return $newdata;
> }
ZeldorBlat wrote:
>> $value = str_replace(array("\r", "\n", "\t"), '', $value);
Ewoud Dronkert wrote:
> $value = preg_replace('/[\r\n\t]+/', '', $value);
Interesting. So what would the preferred method be or is that just
splitting hairs?
Navigation:
[Reply to this message]
|