rfc:array_column_results_grouping
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:array_column_results_grouping [2021/11/28 11:38] – created 7snovic | rfc: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: | + | * Version: |
* Date: 2021-11-28 | * Date: 2021-11-28 | ||
* Author: Hassan Ahmed, 7snovic@gmail.com | * Author: Hassan Ahmed, 7snovic@gmail.com | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | array_column ignores | + | This RFC is to implement a new function to PHP that upgrades |
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC is adding | + | This RFC is to add a new function called array_group |
+ | <code php> | ||
+ | |||
+ | The current behavior is when you have multiple elements share the same key, it will be overwritten. | ||
+ | let' | ||
<code php> | <code php> | ||
- | array_column(array | + | <?php |
+ | |||
+ | $array | ||
+ | [' | ||
+ | [' | ||
+ | [' | ||
+ | [' | ||
+ | [' | ||
+ | ]; | ||
</ | </ | ||
- | Or we can implement it as a new function | + | when we use array_column |
- | <code php> | + | |
- | And keep the same parameters. | + | <code php> |
+ | print_r(array_column($array, | ||
+ | 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 | ||
+ | ) | ||
+ | |||
+ | ) | ||
+ | </ | ||
+ | |||
+ | 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> | ||
+ | print_r(array_group($array, | ||
+ | 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 | ||
+ | ) | ||
+ | |||
+ | ) | ||
+ | |||
+ | ) | ||
+ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 32: | Line 127: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss the proposed voting options. | + | Yes/No vote. |
+ | |||
+ | ===== Voting ===== | ||
+ | |||
+ | Started at : 2021-12-21 | ||
+ | Ends at : 2022-01-04 | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | [[https:// | + | [[https:// |
rfc/array_column_results_grouping.1638099489.txt.gz · Last modified: 2021/11/28 11:38 by 7snovic