3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ["abc", "defs", "ghi"]; $b = ["abcs", "def", "ghis"]; $temp = array_map(null, $a, $b); function combinations($arrays) { $result = []; $arrays = array_values($arrays); $sizeIn = sizeof($arrays); $size = $sizeIn > 0 ? 1 : 0; foreach ($arrays as $array) { $size = $size * sizeof($array); } for ($i = 0; $i < $size; $i++) { $result[$i] = []; for ($j = 0; $j < $sizeIn; $j++) { array_push($result[$i], current($arrays[$j])); } for ($j = ($sizeIn - 1); $j >= 0; $j--) { if (next($arrays[$j])) { break; } elseif (isset($arrays[$j])) { reset($arrays[$j]); } } } return $result; } $res = combinations($temp); $temp = array_map(function($item){ return implode(" ", $item); },$res); foreach($temp as $val){ echo $val."\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
abc defs ghi abc defs ghis abc def ghi abc def ghis abcs defs ghi abcs defs ghis abcs def ghi abcs def ghis

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:
133.96 ms | 405 KiB | 5 Q