如何从 select/option in php 中获取多个数据到一个变量中?

How can i get multiple data into a variable from select/option in php?

假设我选择了前 3 个选项,我想将答案放入一个变量中 $cv = "Option 1,Option 2,Option 3"

<form action="" method="post">
      <select name="ary[]" multiple="multiple">
        <option value="Option 1">Option 1</option>
        <option value="Option 2">Option 2</option>
        <option value="Option 3">Option 3</option>
        <option value="Option 4">Option 4</option>
        <option value="Option 5">Option 5</option>
      </select>
      <input type="submit">
    </form>

    <?php
    $values = $_POST['ary'];

    foreach ($values as $a){
        echo $a;
    }
    ?>

您正在寻找内爆函数

$cv = 内爆(',', $values);