NYCPHP Meetup

NYPHP.org

[nycphp-talk] Trouble Updating an array in a class

Scott Mattocks scott at crisscott.com
Fri Nov 4 11:12:08 EST 2005


Randal Rust wrote:
> 	//pull modules and permissions from request string
> 	foreach($moduleVars as $moduleCode=>$moduleValue){
> 		if(isset($_REQUEST[$moduleCode])){
> 			$moduleValue=$_REQUEST[$moduleCode];
> 			//echo $moduleCode.' = '.$_REQUEST[$moduleCode].'<br />';
> 			}
> 		}
> 
> Can anyone explain why this is happening?

You are not updating the array. You are just updating the variable 
$moduleValue. You should update the array with a line like this:

$moduleVars[$moduleCode] = $_REQUEST[$moduleCode];

Of course you should be sure to scrub the value from the $_REQUEST array 
before you do anything with it, but that doesn't necessarily need to be 
done in the foreach loop.

-- 
Scott Mattocks
scott at crisscott.com
http://www.crisscott.com
http://pear.php.net/user/scottmattocks



More information about the talk mailing list