3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source=json_decode('[{"title":"games","transaction_id":102,"order_id":"a"},{"title":"media","transaction_id":95,"order_id":"b"},{"title":"tv","transaction_id":102,"order_id":"a"},{"title":"jane","transaction_id":42,"order_id":"a"},{"title":"ads","transaction_id":95,"order_id":"b"},{"title":"movie","transaction_id":95,"order_id":"c"}]',true); function merge(array $source) { $result=array(); foreach($source as $node) { $key=$node["transaction_id"]."_".$node["order_id"]; if(!empty($result[$key])) $result[$key][]=$node["title"]; else $result[$key]=array($node["title"]); } return array_values($result); } print_r($source);//Just for debug print_r(merge($source));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [title] => games [transaction_id] => 102 [order_id] => a ) [1] => Array ( [title] => media [transaction_id] => 95 [order_id] => b ) [2] => Array ( [title] => tv [transaction_id] => 102 [order_id] => a ) [3] => Array ( [title] => jane [transaction_id] => 42 [order_id] => a ) [4] => Array ( [title] => ads [transaction_id] => 95 [order_id] => b ) [5] => Array ( [title] => movie [transaction_id] => 95 [order_id] => c ) ) Array ( [0] => Array ( [0] => games [1] => tv ) [1] => Array ( [0] => media [1] => ads ) [2] => Array ( [0] => jane ) [3] => Array ( [0] => movie ) )

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:
37.93 ms | 403 KiB | 8 Q