3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allTags = [ 0 => [ "name" => "TAG-ONE", "video" => "64070,64076,64110,64111", ], 1 => [ "name" => "TAG-TWO", "video" => "64070,64076,64110,64111", ], 2 => [ "name" => "TAG-THREE", "video" => "64111", ] ]; $video_ids = array_flip(array_unique(explode(",",implode(",",array_column($allTags,'video'))))); $result = array_map(function($id){ return ['name' => '','video' => $id]; },array_flip($video_ids)); array_walk($allTags,function($tag_data) use (&$result,&$video_ids){ $ids = explode(",",$tag_data['video']); foreach($ids as $id) $result[$video_ids[$id]]['name'] = empty($result[$video_ids[$id]]['name']) ? $tag_data['name'] : $result[$video_ids[$id]]['name'] . "," . $tag_data['name']; }); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [name] => TAG-ONE,TAG-TWO [video] => 64070 ) [1] => Array ( [name] => TAG-ONE,TAG-TWO [video] => 64076 ) [2] => Array ( [name] => TAG-ONE,TAG-TWO [video] => 64110 ) [3] => Array ( [name] => TAG-ONE,TAG-TWO,TAG-THREE [video] => 64111 ) )

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.63 ms | 402 KiB | 8 Q