I'm creating a simple HTML Select Menu using PHP from an array as follows:
$output = '';
foreach($symptoms as $symptom) {
$symptom = htmlspecialchars($symptom);
if ($symptom == $record->getField('PatientSymptom')) {
$output = "<option value='".$symptom."' selected='selected' >$symptom</option>";
} else {
$output = "<option value='".$symptom."'>$symptom</option>";
}
echo $output;
}
This creates the HTML select menu from the $symptoms
array successfully, but the original value stored in the input field that I'm displaying might not be part of the $symptoms
array. I need to add this to the select menu in this case but not sure the best way to go about this.
I'm storing the original value in a variable: $patientSymptom
What's the best way to check if $patientSymptom
isn't in the $symptoms
array and add that to the select menu I'm creating?