如何将多选的值转换为echo语句?

时间:2016-06-09 19:53:20

标签: javascript php html email select

我试图将多选的值列入php电子邮件表单。变量是name =" variable []"

我不知道如何去做,所以任何建议都很棒

  $message = "<html><head><title></title></head>
        <body>
            <p>Sentence".$_POST['somevarriable']."</p>
            <p>Another Sentence". [I want to put an array here]."</p>
        </body>
        </html>";

1 个答案:

答案 0 :(得分:1)

这样的东西? (未测试)

$message = "
    <html>
        <head><title></title></head>
        <body>
            <p>Sentence" .$_POST['somevarriable']. "</p>
            <p>Another Sentence "
    ;

    foreach ($_POST['variable'] as $selectedOption){
        $message .= $selectedOption . ' ';
    }

    $message .= "
            </p>
        </body>
    </html>
    ";

参考:

How to get multiple selected values of select box in php?