PCHomepage
Programmer
In trying to select multiple values from a form drop down (select) list, I am not sure how to use the results.
For example, the code below gives me a comma-separated list but it also puts a comma at the end that causes issues.
However, I need the results to be as a string variable but when I try the following, it gives only the last value. I am quite rusty in PHP so can anyone help get me going?
Thanks!
For example, the code below gives me a comma-separated list but it also puts a comma at the end that causes issues.
Code:
if(!empty($_POST['Clinic'])) {
if (is_array($_POST['Clinic'])) {
foreach($_POST['Clinic'] as $key => $val) {
echo $val. ",";
}
}
}
However, I need the results to be as a string variable but when I try the following, it gives only the last value. I am quite rusty in PHP so can anyone help get me going?
Code:
if(!empty($_POST['Clinic'])) {
if (is_array($_POST['Clinic'])) {
foreach($_POST['Clinic'] as $key => $val) {
$GetClinic = $val;
}
}
}
Thanks!