How to reverse this array and use duplicate values as key in the new array

后端 未结 1 1068
南旧
南旧 2020-12-21 10:36

I am trying to make my code accept multiple choices from a set of filters, this is the result I have come to so far through the checkboxes and getting the elements selected.

1条回答
  •  粉色の甜心
    2020-12-21 11:31

    $grouped = array();
    foreach ($input as $choice => $group) {
        $grouped[$group][] = $choice;
    }
    
    var_dump($grouped);
    

    0 讨论(0)
提交回复
热议问题