3v4l.org

run code in 300+ PHP versions simultaneously
<?php // function to generate and print all N! permutations of $str. (N = strlen($str)). function permute($str,$i,$n,$len) { global $ret; if ($i == $n) { if(in_array(substr($str,0,$len),$ret)==false){$ret[]=substr($str,0,$len);} }else { for ($j = $i; $j < $n; $j++) { swap($str,$i,$j); permute($str, $i+1, $n, $len); swap($str,$i,$j); // backtrack. } } } // function to swap the char at pos $i and $j of $str. function swap(&$str,$i,$j) { $temp = $str[$i]; $str[$i] = $str[$j]; $str[$j] = $temp; } $ret = array(); $str = "123"; permute($str,0,2, 3); // call the function. ?>
Output for git.master, git.master_jit, rfc.property-hooks

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