3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = range('a', 'g'); function permute($items, $perms = array( )) { if (empty($items)) { print '<pre>'; print_r($perms); } else { for ($i = count($items) - 1; $i >= 0; --$i) { $newitems = $items; $newperms = $perms; list($foo) = array_splice($newitems, $i, 1); array_unshift($newperms, $foo); permute($newitems, $newperms); } } } permute($items);

preferences:
35.73 ms | 402 KiB | 5 Q