I am trying to write a func to replace a large chunk of repetitive code:
$inputVals = array( $siteId, $siteName, $numHspaBbu, $numLteBbu, $extAlarmsTerminated, $cellLowPower );
function updateVarVals( $inputVals ) { // assign values to $vars after Update button clicked
foreach( $inputVals as $val ) {
if ( $_POST[ $val ] !== "" ) { // if $_POST value is not empty then assign to $var and corresponding $_SESSION value
$val = $_SESSION[ $val ] = $_POST[ $val ];
} else { // re-assign $_SESSION value to $var
$val = $_SESSION[ $val ];
} // close IF
} // close FOREACH
} // close FUNC
updateVarVals( $inputVals );
but no matter how I quote $val
I keep getting:
Notice: Undefined index: <$val value> in C:\xampp\htdocs\database on line 145.
for every iteration of the loop. Why is PHP expecting variable values to be defined here?