3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ [ 'question_category' => 'Engagement', 'result' => '6.6667', 'employee_first_name' => 'Person A', ], [ 'question_category' => 'Tenure', 'result' => '7.6667', 'employee_first_name' => 'Person A', ], [ 'question_category' => 'Engagement', 'result' => '7.6667', 'employee_first_name' => 'Person B', ], [ 'question_category' => 'Tenure', 'result' => '8.3333', 'employee_first_name' => 'Person B', ], ]; $grouped = []; foreach($data as $row){ // I think this is the mapping? If anything else exists, // this will throw $xOrY = match($row['question_category']){ 'Engagement' => 'x', 'Tenure' => 'y', }; // Group by name $grouped[$row['employee_first_name']][$xOrY] = $row['result']; } // Remove the names (optional) $grouped = array_values($grouped); var_dump($grouped);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> array(2) { ["x"]=> string(6) "6.6667" ["y"]=> string(6) "7.6667" } [1]=> array(2) { ["x"]=> string(6) "7.6667" ["y"]=> string(6) "8.3333" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.42 ms | 405 KiB | 5 Q