note 24774 added to function.str-replace

From: Date: Wed, 28 Aug 2002 11:29:16 +0000
Subject: note 24774 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-35897@lists.php.net to get a copy of this message
I made this to parse values returned in a form, but to preserve formatting so that it doesn't get removed in the "remove anything but alphanumeric" line... Probably not elegant, but it works. foreach ($_POST as $key => $val) { $val = preg_replace("(\r\n|\n|\r)", "#", $val); $val = preg_replace("/[^0-9a-z -#]/i",'', $val); // strip anything we don't want $val = str_replace("#", "*", $val); // * Put a p or br here. $_POST[$key] = $val; } -- http://www.php.net/manual/en/function.str-replace.php http://master.php.net/manage/user-notes.php?action=edit+24774 http://master.php.net/manage/user-notes.php?action=delete+24774 http://master.php.net/manage/user-notes.php?action=reject+24774

« previous php.notes (#35897) next »