I'm completely baffled by the following problem:
I am trying to iterate through a HTTP_GET_VARS array and register each key/value exactly how they appear in the GET array. To do this I'm using ${$key}=$val but whenever I invoke session_register($key) at the end of the iteration, the value of $key for the FIRST array key only gets changed to the value of the key in the iteration.
That's the best I can describe. Given below is the code (with print_r($HTTP_GET_VARS) to see what's happening to the GET array) and the output:
print_r ($HTTP_GET_VARS);
echo"<br>";
foreach($HTTP_GET_VARS as $key => $val) {
${$key}=$val;
session_register("$key");
print_r($HTTP_GET_VARS);
echo"<br>";
}
print_r($HTTP_SESSION_VARS);
This gives the output:
//GET ARRAY BEFORE LOOP
Array ( [sell_id] => 15 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
Array ( [sell_id] => 15 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
Array ( [sell_id] => 115 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
Array ( [sell_id] => 2.8 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
Array ( [sell_id] => 1 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
//SESSION_ARRAY ARFTER LOOP
Array ( [sell_id] => 1 [man_id] => 115 [class_id] => 2.8 [setclass] => 1 )
You see how the value of the first key of the GET array ($__GET["sell_id"]) is changing with each iteration of the loop.... how can I stop this, because the final SESSION array is being affected