Page 1 of 1

Removing space

Posted: Mon Dec 20, 2004 8:24 am
by snicolas
Hi,

I am using this to remove unwanted tags from my posted data, but would like to keep the "space" if they entered one.

How can i modify this?
$s = ereg_replace("[^A-Za-z0-9]", "", $s);

thanks

s

Posted: Mon Dec 20, 2004 3:27 pm
by rehfeld

Code: Select all

// this will allow a space
$s = ereg_replace("[^A-Za-z0-9 ]", "", $s);
// or this will allow whitespace characters (probably tab, space, new line, carriage return)
$s = ereg_replace("[^A-Za-z0-9\s]", "", $s);
you might wanna take a look at at php's strip_tags()