3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_combinations($arrays) { $result = array(array()); foreach ($arrays as $property => $property_values) { $tmp = array(); foreach ($result as $result_item) { foreach ($property_values as $property_value) { $tmp[] = array_merge($result_item, array($property => $property_value)); } } $result = $tmp; } return $result; } $in = [ 1 => 'мама', 3 => 'раму', 7 => 'раму', 8 => 'мыла', 13 => 'мама', ]; $flipped = []; foreach ($in as $key => $value) { $flipped[$value][] = $key; } $flipped = array_values($flipped); $result = get_combinations($flipped); var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => 1, 1 => 3, 2 => 8, ), 1 => array ( 0 => 1, 1 => 7, 2 => 8, ), 2 => array ( 0 => 13, 1 => 3, 2 => 8, ), 3 => array ( 0 => 13, 1 => 7, 2 => 8, ), )

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.41 ms | 406 KiB | 5 Q