Re: How to loop the HTTP_POST_VARS array?

From: Date: Mon, 21 May 2001 11:05:37 +0000
Subject: Re: How to loop the HTTP_POST_VARS array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53693@lists.php.net to get a copy of this message
Maxim, This is great. Thank you very much !! I really appreciate your explanation since I did not get anything this good in any of my books. Since all the values that I need to retrieve are CheckBoxes that are Named C1,C2,C3,C... I have done the following and it worked : function RetrieveItens() { global $Itens; global $HTTP_POST_VARS; $index = count($HTTP_POST_VARS); for($i=1; $i <= $index; $i++) { if (isset($HTTP_POST_VARS["C$i"])) $Itens[] = $HTTP_POST_VARS["C$i"]; } $index = count($Itens); return $index; } // function RetrieveItens ----- Original Message ----- From: "Maxim Maletsky" <maxim@japaninc.com> To: "'Carlos Fernando Scheidecker Antunes'" <nando@antunes.eti.br>; "PHP-GENERAL" <PHP-GENERAL@lists.php.net> Sent: Monday, May 21, 2001 1:00 AM Subject: RE: [PHP] How to loop the HTTP_POST_VARS array? no, you are trying to get an $HTTP_POST_VAR[integer]... it is not there. The keys are your variable names, therefore this is correct: foreach($HTTP_POST_VARS as $key=>$val) { $itens[] = $val; } will fit everything form ..POST_VARS into $itens array. BUT you'll loose all the key names, knowing nothing of where these values came from. try rather do this: foreach($HTTP_POST_VARS as $key=>$val) { $itens[$key] = $val; } this will result you true: if($HTTP_POST_VARS['var_name'] == $itens['var_name']) {} Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Carlos Fernando Scheidecker Antunes [mailto:nando@antunes.eti.br] Sent: Monday, May 21, 2001 12:43 PM To: PHP-GENERAL Subject: [PHP] How to loop the HTTP_POST_VARS array? Importance: High Oops. I've got a typo : $itens[] Here's the correct code : Hello all, I'm trying to loop the $HTTP_POST_VARS variable like an array like this : $index = count($HTTP_POST_VARS); for($i=0; i < $index; i++) { $itens[] = $HTTP_POST_VARS[$i]; } But it is not working. Can anoyone tell me how to do it? Thanks, Carlos Fernando. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#53693) next »