Hello, I started to edit the array_column function to accept the fourth parameter to group the similar results
The current behavior is when you have multiple elements share the same key, it will be overwritten. let's assume that we have the following. ``` <?php $array = [ ['id' => 1, 'name' => 'hassan'], ['id' => 2, 'name' => 'sara'], ['id' => 3, 'name' => 'selim'], ['id' => 4, 'name' => 'chris'], ['id' => 5, 'name' => 'sara'], ]; ``` when we use array_column with this the output will be ``` print_r(array_column($array, null, 'name')); Array ( [hassan] => Array ( [id] => 1 [name] => hassan ) [sara] => Array ( [id] => 5 [name] => sara ) [selim] => Array ( [id] => 3 [name] => selim ) [chris] => Array ( [id] => 4 [name] => chris ) ) ``` I'd added a fourth parameter to array_column to group the results in an indexed array to group all the similar elements, so we can use : ``` print_r(array_column($array, null, 'name', true)); Array ( [hassan] => Array ( [0] => Array ( [id] => 1 [name] => hassan ) ) [sara] => Array ( [0] => Array ( [id] => 2 [name] => sara ) [1] => Array ( [id] => 5 [name] => sara ) ) [selim] => Array ( [0] => Array ( [id] => 3 [name] => selim ) ) [chris] => Array ( [0] => Array ( [id] => 4 [name] => chris ) ) ) ``` not sure if we need to implement this as a new function `array_column_group` or we can keep the fourth optional parameter. however, I have an issue in creating an account on the wiki so I can not create an RFC. it keeps giving me this error `That wasn't the answer we were expecting` no matter the email/user name I use PR number: https://github.com/php/php-src/pull/7698 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php