rfc:array_column_results_grouping

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:array_column_results_grouping [2021/11/28 11:48] 7snovicrfc:array_column_results_grouping [2022/01/14 17:10] (current) – RFC has been declined cmb
Line 1: Line 1:
-====== PHP RFC: array_column results grouping ====== +====== PHP RFC: Add array_group function ====== 
-  * Version: 1.0+  * Version: 2.0
   * Date: 2021-11-28   * Date: 2021-11-28
   * Author: Hassan Ahmed, 7snovic@gmail.com   * Author: Hassan Ahmed, 7snovic@gmail.com
-  * Status: Draft+  * Status: Declined
   * First Published at: https://wiki.php.net/rfc/array_column_results_grouping   * First Published at: https://wiki.php.net/rfc/array_column_results_grouping
  
 ===== Introduction ===== ===== Introduction =====
-array_column ignores the duplicated rows for each similar columnt/index.+This RFC is to implement a new function to PHP that upgrades the functionality of array_column to group similar results that share the same index_key into a multidimensional array. the current behavior of array_column is to return a single result and ignore the rest of the results that share the same index.
  
 ===== Proposal ===== ===== Proposal =====
-This RFC is adding a new boolean parameter to array_column to determine it's behaviour of grouping or not.   +This RFC is to add a new function called array_group 
- +<code php>array_group(array $array, int|string|null $column_key, int|string|null $index_key = null)</code>
-<code php> +
-array_column(array $array, int|string|null $column_key, int|string|null $index_key = null, $grouping = null): array +
-</code> +
- +
-Or we can implement it as a new function with something like +
-<code php>array_column_group(array $array, int|string|null $column_key, int|string|null $index_key = null)</code> +
- +
-And keep the same parameters.+
  
 The current behavior is when you have multiple elements share the same key, it will be overwritten. The current behavior is when you have multiple elements share the same key, it will be overwritten.
Line 69: Line 61:
 </code> </code>
  
-The RFC implements a fourth parameter to array_column to group the results in an indexed array to group all the similar elements, so we can use :+The RFC implements a new function called array_group to group the results in an indexed array to group all the similar elements, so we can use :
  
 <code php> <code php>
-print_r(array_column($array, null, 'name', true));+print_r(array_group($array, null, 'name'));
 Array Array
 ( (
Line 136: Line 128:
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
 Yes/No vote. Yes/No vote.
 +
 +===== Voting =====
 +
 +Started at : 2021-12-21
 +Ends at : 2022-01-04
 +
 +<doodle title="Add array_group function to PHP" auth="hassan" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Implementation ===== ===== Implementation =====
-[[https://github.com/php/php-src/pull/7698|Support grouping in array_column]]+[[https://github.com/php/php-src/pull/7698|Implementing array_group function]]
  
rfc/array_column_results_grouping.1638100137.txt.gz · Last modified: 2021/11/28 11:48 by 7snovic