store multiple select option into a PHP array

若如初见. 提交于 2019-11-28 10:20:14

Use name as name="access_list[]" without space.

And you can get selected options with $_POST['access_list']

$_POST['access_list'] is array that contains selected options

Replace your select tag with this:

<select name="access_list[]" size="7" multiple="multiple">

If you want to get the array, you can do it like this:

$data = $_POST['access_list'];
print_r($data);

store as array then in your php is like this.

<?php

    $access_list = $_POST['access_list'];

    foreach($access_list as $value)
    {
        //Do your code Here
    }


?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!