Re: foreach and form submission.
| From: | Igor Escobar | Date: | Mon, 30 Mar 2009 13:27:23 +0000 |
| Subject: | Re: foreach and form submission. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290826@lists.php.net to get a copy of this message | ||
Try this...
$_POST = array_map('stri_tags', $_POST);
Igor Escobar
systems analyst & interface designer
www . igorescobar . com
On Sat, Mar 28, 2009 at 6:21 PM, Angus Mann <angusmann@pobox.com> wrote:
> Thanks Ashley...that did the trick.
> After reading about the limitations of strip_tags I decided to just replace
> the bad bits as below...
> It still uses your "foreach" suggestion but replaces "<" and
> ">" with "("
> and ")" instead of stripping tags.
>
> I think I will extend the good and bad arrays to deal with magic quotes
> also !
>
> $bad = array('<','<','<', '>',
> '>', '>');
> $good = array('(', '(', '(', ')', ')',
> ')');
> foreach ($_POST as $key => $value) {
> $_POST[$key] = str_ireplace($bad, $good, $value);
>
> }
>
>
>
>
>
> I'd do something like this, so as to preserve the original post data
>> array:
>>
>> $data = Array();
>> foreach($_POST as $key => $value)
>> {
>> $data[$key] = strip_tags($value);
>> }
>>
>> Note that strip_tags() will not be able to decently clean up messy code
>> (i.e. code where the opening or closing tags themselves aren't formed
>> properly)
>>
>>
>> Ash
>> www.ashleysheridan.co.uk
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>