I wrote this function recently when I could not find it in the PHP function list. Please provide any optimizations you discover! function permute($array) { $results = array(); if (count($array) == 1) { $results[] = $array; } else { for ($i = 0; $i < count($array); $i++) { $first = array_shift($array); $subresults = permute($array); array_push($array,… Continue reading Permute an array in PHP