3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['alteration1', 'alteration4',], ['alteration2','alteration3'], ['alteration2','alteration3'], [] ]; $combinations = [[]]; foreach($data as $index => $current_data){ $current_data = array_unique($current_data); if(empty($current_data)) continue; $temp_combinations = []; foreach($current_data as $value){ foreach($combinations as $each_combination){ $temp_combinations[] = array_merge($each_combination,[$value]); } } $combinations = $temp_combinations; } $set = []; $unique_combinations = []; foreach($combinations as $each_combination){ natsort($each_combination); $serialized_form = implode(",",$each_combination); if(isset($set[$serialized_form])) continue; if(empty($each_combination)) continue; $unique_combinations[] = $each_combination; $set[$serialized_form] = true; } print_r($unique_combinations);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [0] => alteration1 [1] => alteration2 [2] => alteration2 ) [1] => Array ( [1] => alteration2 [2] => alteration2 [0] => alteration4 ) [2] => Array ( [0] => alteration1 [2] => alteration2 [1] => alteration3 ) [3] => Array ( [2] => alteration2 [1] => alteration3 [0] => alteration4 ) [4] => Array ( [0] => alteration1 [1] => alteration3 [2] => alteration3 ) [5] => Array ( [1] => alteration3 [2] => alteration3 [0] => alteration4 ) )

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