3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = 'ABC1'; permute(str_split($str), 0, strlen($str)); function permute($arr, $i, $n) { if ($i == $n) { printArray($arr); return; } for ($j = $i; $j < $n; $j += 1) { swapArrayValues($arr, $i, $j); permute($arr, $i + 1, $n); swapArrayValues($arr, $i, $j); } } function swapArrayValues(&$array, $i, $j) { $tmp = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $tmp; } function printArray($arr) { echo implode($arr, ' ') . "\n"; }
Output for 5.0.0 - 7.1.0
A B C 1 A B 1 C A C B 1 A C 1 B A 1 C B A 1 B C B A C 1 B A 1 C B C A 1 B C 1 A B 1 C A B 1 A C C B A 1 C B 1 A C A B 1 C A 1 B C 1 A B C 1 B A 1 B C A 1 B A C 1 C B A 1 C A B 1 A C B 1 A B C
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_split() in /in/DSo4D on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: str_split() in /in/DSo4D on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: str_split() in /in/DSo4D on line 6