$grouped = array();
foreach ($input as $choice => $group) {
$grouped[$group][] = $choice;
}
var_dump($grouped);
More Related Contents:
- Merge multiple associative arrays and add missing columns with a default value
- Merge two numerically-keyed associative arrays and preserve the original keys
- PHP – File to Associative Array with 1 key and two values attached
- In PHP, how do you change the key of an array element?
- Convert backslash-delimited string into an associative array
- Is there a way to find out how “deep” a PHP array is?
- Replace keys in an array based on another lookup/mapping array
- Associative array, sum values of the same key
- How to sort a date array in PHP
- Convert an associative array to a simple array of its values in php
- PHP combine two associative arrays into one array
- Display array values in PHP
- Comment associative array in PHP Documentor
- PHP – Merge two arrays (same-length) into one associative?
- Iterating over a complex Associative Array in PHP
- Generate an associative array from an array of rows using one column as keys and another column as values
- Merging two arrays with the “+” (array union operator) How does it work?
- Group rows in an associative array of associative arrays by column value and preserve the original first level keys
- Prepend associative array elements to an associative array
- Custom key-sort a flat associative based on another array
- PHP/SQL Insert Error when using Named Placeholders
- Implementing a simple lookup array
- Conditionally add associative element to array
- array_diff to compare two associative arrays
- Sorting a multidimensional array in PHP? [duplicate]
- How to group a multidimensional array by a particular subarray value?
- Converting a SimpleXML Object to an Array [closed]
- Add elements to array which has gapped numeric keys to form an indexed array / list
- Return only duplicated entries from an array (case-insensitive)
- How to get array key from corresponding array value?