Solved

Need to find key with value, replace that value

Posted on 2008-09-29
2
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

631 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