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.3.0 - 7.1.0
A B C 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B C 1 A B 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B 1 C A B C 1 A C B 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C B 1 A C 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B A C B 1 A 1 C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 C B A 1 B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 B C A 1 C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B A C B 1 A 1 C B A 1 B C A B 1 C A B C 1 B A C 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A C 1 B A 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A 1 C B A C 1 B C A 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C A 1 B C 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 C A B 1 A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 A C B 1 C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A B 1 A C B A 1 C B A C 1 C B A 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B A 1 C B 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B 1 A C B A 1 C A B 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A B 1 C A 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B C A B 1 C 1 A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 A B C 1 B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 B A C 1 A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B C A B 1 C 1 A B C 1 B A C B 1 A C B A 1 1 B C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B C A 1 B A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B A C 1 B C A 1 C B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C B A 1 C A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B 1 C B A 1 A C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A C B 1 A B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A B C 1 A C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B 1 C B A 1 A C B 1 A B C 1 B A C 1 B C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A B 1 A C B A 1 C B A C 1 C B 1 A C B A 1 C 1 B A C 1 A B C A 1 B C A B 1 1 C B A 1 C A B 1 B C A 1 B A C 1 A B C 1 A C B A C 1 B A C B 1 A 1 C B A 1 B C A B 1 C A B C 1
Output for 5.0.0 - 5.2.17
A B C 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B C 1 A B 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A B 1 C A B C 1 A C B 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C B 1 A C 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B A C B 1 A 1 C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 C B A 1 B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 A 1 B C A 1 C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 A C 1 B A C B 1 A 1 C B A 1 B C A B 1 C A B C 1 B A C 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A C 1 B A 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A 1 C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B A 1 C B A C 1 B C A 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C A 1 B C 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 C A B 1 A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 B 1 A C B 1 C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A B 1 A C B A 1 C B A C 1 C B A 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B A 1 C B 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B 1 A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C B 1 A C B A 1 C A B 1 Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A B 1 C A 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B C A B 1 C 1 A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 A B C 1 B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 C 1 B A C 1 A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 C A 1 B C A B 1 C 1 A B C 1 B A C B 1 A C B A 1 1 B C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B C A 1 B A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B A C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 B A C 1 B C A 1 C B A Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C B A 1 C A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B 1 C B A 1 A C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A C B 1 A B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A B C Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 A B C 1 A C B Notice: Undefined offset: 4 in /in/sZS6n on line 25 1 C A B 1 C B A 1 A C B 1 A B C 1 B A C 1 B C A Notice: Undefined offset: 4 in /in/sZS6n on line 25 B C 1 A B C A 1 B 1 C A B 1 A C B A 1 C B A C 1 C B 1 A C B A 1 C 1 B A C 1 A B C A 1 B C A B 1 1 C B A 1 C A B 1 B C A 1 B A C 1 A B C 1 A C B A C 1 B A C B 1 A 1 C B A 1 B C A B 1 C A B C 1
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_split() in /in/sZS6n 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/sZS6n 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/sZS6n on line 6