note 7304 modified in strip_tags by ronabop

From: Date: Mon, 02 Oct 2000 11:31:23 +0000
Subject: note 7304 modified in strip_tags by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-5933@lists.php.net to get a copy of this message
New code for stripping tags from form input. The reason for the addition is that the original code gave me trouble when trying to pass arrays via a form. This seems to fix the problem: // Authors: // tomjr@tx3.net // jkeppens@xs4all.be // dsalada@adventassociates.com if(is_array($HTTP_POST_VARS)) { reset($HTTP_POST_VARS); while (list($key, $val) = each($HTTP_POST_VARS)) { if (is_array($val)) { while (list($akey,$aval) = each($val)) { $HTTP_POST_VARS[$key][$akey] = strip_tags($aval); $$key[$akey] = strip_tags($aval); } } else { $HTTP_POST_VARS[$key] = strip_tags($val); $$key = strip_tags($val); } } } if(is_array($HTTP_GET_VARS)) { reset($HTTP_GET_VARS); while (list($key, $val) = each($HTTP_GET_VARS)) { if (is_array($val)) { while (list($akey,$aval) = each($val)) { $HTTP_GET_VARS[$key][$akey] = strip_tags($aval); $$key[$akey] = strip_tags($aval); } } else { $HTTP_GET_VARS[$key] = strip_tags($val); $$key = strip_tags($val); } } } if(is_array($HTTP_COOKIE_VARS)) { reset($HTTP_COOKIE_VARS); while (list($key, $val) = each($HTTP_COOKIE_VARS)) { if (is_array($val)) { while (list($akey,$aval) = each($val)) { $HTTP_COOKIE_VARS[$key][$akey] = strip_tags($aval); $$key[$akey] = strip_tags($aval); } } else { $HTTP_COOKIE_VARS[$key] = strip_tags($val); $$key = strip_tags($val); } } } http://www.php.net/manual/function.strip-tags.php

« previous php.notes (#5933) next »