Solved

Need to find key with value, replace that value

Posted on 2008-09-29
2
233 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Undefined variable problem 5 32
warning code: class php incomplete message 6 27
while read ID; do 4 53
CURL sending XML without spaces PHP 5 28
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

679 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