store multiple select option into a PHP array

前端 未结 3 1651
北海茫月
北海茫月 2020-12-10 05:58

I have an selectbox list Is it possible to select multiple option:


                        
    
提交评论

  • 2020-12-10 06:30

    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

    0 讨论(0)
  • 2020-12-10 06:37

    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);
    
    0 讨论(0)
  • 提交回复
    热议问题