3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WF" ], 1 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "WFR" ], 2 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PUSH", "chs_name" => "STK Food" ], 3 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "4 Stars" ], 4 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "5 Stars" ], 5 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Modern Thai" ], 6 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "BBQ Buffet" ], 7 => [ "product_code" => "67021687", "product_name" => "Spaces", "cha_sty_id" => "PULL", "chs_name" => "Chinese" ] ]; $res = []; array_walk($array, function($v, $k) use (&$res){ if(in_array($v['product_code'], array_column($res, 'product_code'))){ array_push($res[$v['product_code']]["push"], $v['chs_name']); array_push($res[$v['product_code']]["pull"], $v['chs_name']); }else{ $res[$v['product_code']] = [ "product_code" => $v['product_code'], "product_name" => $v['product_name'], "push" => [$v['chs_name']], "pull" => [$v['chs_name']] ]; } }); echo '<pre>'; print_r(array_values($res));
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [product_code] => 67021687 [product_name] => Spaces [push] => Array ( [0] => WF [1] => WFR [2] => STK Food [3] => 4 Stars [4] => 5 Stars [5] => Modern Thai [6] => BBQ Buffet [7] => Chinese ) [pull] => Array ( [0] => WF [1] => WFR [2] => STK Food [3] => 4 Stars [4] => 5 Stars [5] => Modern Thai [6] => BBQ Buffet [7] => Chinese ) ) )

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:
122.06 ms | 407 KiB | 5 Q