note 24774 deleted from function.str-replace by felipe
| From: | felipe@php.net | Date: | Sun, 23 Mar 2008 23:03:24 +0000 |
| Subject: | note 24774 deleted from function.str-replace by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137414@lists.php.net to get a copy of this message | ||
Note Submitter: paul at atomicrevs dot net
----
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.
<?php
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;
}
?>