permute

Description

Calculates all possible permutations of an array.

Syntax

array permute (array $array)



Parameter $array

Expected type: Array
Description: An array with at least two elements



Return value

Expected type: Array of arrays
Description: $orders, an array showing all possible arrays of the same length that can be made from the items in $array


Notes

  • Does not check for duplicate values
  • Assumes that there are at least two items in the array
  • Not a recursive function
  • See wikipedia for more info on permutations
Advertisement: