3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = array('A','B','A'); permute($str, 0, count($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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /in/86vi2:30 Stack trace: #0 /in/86vi2(30): implode(Array, ' ') #1 /in/86vi2(11): printArray(Array) #2 /in/86vi2(17): permute(Array, 3, 3) #3 /in/86vi2(17): permute(Array, 2, 3) #4 /in/86vi2(17): permute(Array, 1, 3) #5 /in/86vi2(6): permute(Array, 0, 3) #6 {main} thrown in /in/86vi2 on line 30
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 A B A Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 A A B Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 B A A Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 B A A Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 A B A Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/86vi2 on line 30 A A B
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.26
A B A A A B B A A B A A A B A A A B

preferences:
300.75 ms | 404 KiB | 460 Q