I have a question about the best way to refer to Keys and Values in an Array.
In my code, I build an array like this...
PHP Code:
// ************************
// Build Decision Array. *
// ************************
foreach($_POST['friendRequestDecision'] as $requestorID => $decision){
// Cast to Integers.
$requestorID = (int)$requestorID;
$decision = (int)$decision;
// Validate Request Decision.
if (($decision == 0) || ($decision == 1) || ($decision == 2)){
// Valid Response.
// Take Submitted Form Data and put into Decision Array.
$decisionArray[$requestorID] = $decision;
}else{
// Invalid Response.
// Display Error.
}
And then a little farther down in my code I iterate through the array items to take action...
PHP Code:
// ******************************
// Attempt to Update Decisions. *
// ******************************
foreach($decisionArray as $requestorID => $decision){
}
In the loop above, which is the proper way to refer to my Array Values...
Option #1:
PHP Code:
if ($decisionArray[$requestorID] == 0){
OR...
Option #2:
PHP Code:
if ($decision == 0){
Sincerely,
Debbie