3v4l.org

run code in 300+ PHP versions simultaneously
<?php foreach (cartesian(expand_pattern('a..c'), 3) as $option) { echo "$option\n"; } function expand_pattern($pattern) { $bias = 0; $flags = PREG_SET_ORDER | PREG_OFFSET_CAPTURE; preg_match_all('/(.)\.\.(.)/', $pattern, $matches, $flags); foreach ($matches as $match) { $range = implode('', range($match[1][0], $match[2][0])); $pattern = substr_replace( $pattern, $range, $bias + $match[1][1], $match[2][1] - $match[1][1] + 1); $bias += strlen($range) - 4; } return $pattern; } function cartesian($pattern, $length) { $choices = strlen($pattern); $indexes = array_fill(0, $length, 0); $resets = 0; while ($resets != $length) { $result = ''; for ($i = 0; $i < $length; ++$i) { $result .= $pattern[$indexes[$i]]; } yield $result; $resets = 0; for ($i = $length - 1; $i >= 0 && ++$indexes[$i] == $choices; --$i) { $indexes[$i] = 0; ++$resets; } } }
Output for git.master, git.master_jit, rfc.property-hooks
aaa aab aac aba abb abc aca acb acc baa bab bac bba bbb bbc bca bcb bcc caa cab cac cba cbb cbc cca ccb ccc

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.42 ms | 401 KiB | 8 Q