尝试$ _POST多个选定的选项,但没有获得任何选定的选项

This is a form and one of the options allows for more than one selection (name="mission[]"). Although I have read some remarks about using brackets in the name, I still keep getting a blank in that section of the form. Any thoughts? (context: Using PHPMailer and Gmail as SMTP)

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$firstname = trim($_POST["firstname"]);
//more of these

$mission = trim($_POST["mission"]);
$date = trim($_POST["date"]);
$time = trim($_POST["time"]);

//some other code here

//message in email to be sent

$email_body = "";
$email_body = $email_body . "What I am trying to improve at our clinic: " . $mission . "<br>" ;

Here's the html code in a form:

<label for="mission" class="col-sm-3 control-label">What are you trying to improve at your clinic?</label>
<div class="col-sm-9">
   <select name="mission[]"  multiple="multiple" class="form-control" style="max-height:75px">
      <option disabled>(Use the Shift key to select more than one)</option>
      <option  value="Decrease noshows"> Decrease patient no-shows</option>
      <option  value="increase # of patients completing a full episode of care"> Increase number of patients completing care.</option>
      <option  value="Improve clinic reviews"> Improve my clinic's reviews.</option>
      <option  value="Increaes physician referrals"> Increase physician referrals.</option>
      <option  value="increase patient referrals"> Increase patient referrals.</option>
      <option  value="improve overall patient satisfaction"> Improve overall patient satisfaction.</option>
   </select>
</div>

Solution: I went with the following code in the end:

$mission_vals = "";
foreach ($mission as $missionselected){
  $mission_vals .= $missionselected . ", "; 
}

Because you named your select mission[] when you call $_POST["mission"] PHP is returning an array, not a string.

You need something like:

$missionArray = $_POST["mission"];

for ($i=0; $i < count($missionArray); $i++)
{
    $missionArray[$i] = trim($missionArray[$i]);
}

Edit:-- The trimming part, more efficiently:

$missionArray = array_map('trim', $missionArray);