Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove post variable from array 1

Status
Not open for further replies.

hos2

Programmer
Joined
May 6, 2002
Messages
418
Location
NL
I can loop through all the post variables like

Code:
while ( list($field, $value) = each ($HTTP_POST_VARS)) {
	if ($field <> "Submit" ){
		if (is_array($value)){

				$arrayLength = count($value);
				$temparray=array_values($value);	
				for ($i = 0; $i < $arrayLength; $i++){ 
						$temp=$temp .$temparray[$i] ."#";
						}
					$fieldlines=$fieldlines .$field ."='" .$temp ."',";
					$temp="#";
			}else{
			$fieldlines=$fieldlines .$field ."='" .$value ."',";
			}
		
				
	}
    }

but now I also post a variable that I don't want to include in this loop.

I have a var called $country which comes from a select list but when the country is not in the list I like to add it with a field called $newcountry

before the loop starts I want to transfer the value of $newcountry to $country and remove $newcountry from the post array??

is this possible and then how ??


 
In the loop I create an update or an insert statement. normally all the variablenames correspond with a fieldname in the database. but $newcountry doesn't so I want to remove it. I can ofcourse do this in the loop but I want to do it before the loop so the code doesn't become to complex

 
yep that's it. I couldn't find it on php.net in the post manuals

ps would next code also work
Code:
if (len($_POST['newcountry']) >2) {
$_POST['country'] = $_POST['newcountry'];
}
unset($_POST['newcountry']);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top