Solved

Need to find key with value, replace that value

Posted on 2008-09-29
2
232 Views
Last Modified: 2008-09-29
Hello,

The code below I am pulling info from post and placing into a variable.  Now I need to find a specific key in that varable and replace only that.  Any thoughts?

Thanks
foreach($_POST as $key=>$value){
		if ($key!="M_unecpss"){
	//		print "Name KEY=".$key." and VALUE=".$value."<BR>";
			$VARS = $VARS."&".$key."=".$value;
		}
	}
	$VARS = $VARS."&iFind_MSISDN=".$MSISDN;
	//print "Name KEY=iFind_MSISDN and VALUE=".$MSISDN."</P>";
	$VARS=$VARS."&unecpss=".$unecpss;
	//print "Name KEY=enucpss and VALUE=".$unecpss."</P>";
	$VARS=$VARS."&action=both";
	//print "Name KEY=action and VALUE=both</P>";
	$VARS = substr($VARS,1);

Open in new window

0
Comment
Question by:vrmetro
2 Comments
 
LVL 10

Assisted Solution

by:Tyler Laczko
Tyler Laczko earned 200 total points
ID: 22598055
You can reference variables in the POST since it is an array

eg Change POST variable

$_POST['keywantingtochange'] = "new value";
0
 
LVL 82

Accepted Solution

by:
hielo earned 300 total points
ID: 22598069
>>Now I need to find a specific key in that varable and replace only that.  
if( isset($_POST['keyname']) )
{
$_POST['keyname']="new value";
}
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question