3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cross_product($array, $value) { $output = array(); foreach ($array as $arr) { foreach ($value as $val) { $output[] = array_merge($arr, array($val)); } } return $output; } $input = "A1 / B2 - C3 + D4 / E5 / E6 C3 + A5"; $parts = preg_split('/(?<=[A-Za-z0-9])\s+(?=[A-IK-Za-ik-z])|\s+([+-])\s+/', $input, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($parts as &$part) { $part = preg_split('#\s+/\s+#', $part); } $init = array_map(function ($v) { return array($v); }, array_shift($parts)); $outputs = array_reduce($parts, 'cross_product', $init); foreach ($outputs as $output) { echo implode(' ', $output) . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
A1 - C3 + D4 C3 + A5 A1 - C3 + E5 C3 + A5 A1 - C3 + E6 C3 + A5 B2 - C3 + D4 C3 + A5 B2 - C3 + E5 C3 + A5 B2 - C3 + E6 C3 + A5

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:
18.19 ms | 401 KiB | 8 Q