note 17429 added to control-structures.while

From: Date: Sat, 08 Dec 2001 09:29:50 +0000
Subject: note 17429 added to control-structures.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-22064@lists.php.net to get a copy of this message
to itenerate through your a html form's results, i've found the following to work well. note it also check for arrays in a key, e.g. a bunch of <INPUT type='text' name='favorite_colors[]'> if ($HTTP_POST_VARS) { reset($HTTP_POST_VARS); while(list($key, $val) = each($HTTP_POST_VARS)) { if (is_array($val)) { for ($i=0; $i < count($val); $i++){ $val[$i] = trim($val[$i]); $val[$i] = addslashes($val[$i]); //$GLOBALS[$key] = $val[$i]; } } else { $val = trim($val); $val = addslashes($val); //$GLOBALS[$key] = $val; } } } -- http://www.php.net/manual/en/control-structures.while.php http://master.php.net/manage/user-notes.php?action=edit+17429 http://master.php.net/manage/user-notes.php?action=delete+17429 http://master.php.net/manage/user-notes.php?action=reject+17429

« previous php.notes (#22064) next »