Forum Moderators: coopster
I have done the following coding.
PHP Code:
$spitter=$HTTP_POST_VARS;
foreach($spitter as $op=>$val) {
if ($val=="")
$val="Optoinal";
}
foreach ($HTTP_POST_VARS as $temp =>$sub) {
$sub = $temp->$val;
}
the first part of the code is working, but when i again assign new values to HTTP_POST_VARS array its not working, and not taking the new values, i want assign new values from array SPITTER to HTTP_POST_VARS so that in further code i can use HTTP_POST_VARS to insert data into table.
pleas guide me about this.
Thanks
When you use foreach( $array as $key => $value), the $key and $value as visible to your loop are new variables; they are not "pointers" or references to the original array.
What you need to do is re-populate $HTTP_POST_VARS using the $key component, something like this:
foreach($spitter as $op=>$val)
{
if ($val=="") $HTTP_POST_VARS[$op] = "Optoinal";
}