Lexicographic permutation function.
This is a special type of permutation which involves the order of the set. The next lexicographic permutation of '32541' is '34125'. Numerically, it is simply the smallest set larger than the current one.
The benefit of this over a recursive solution is that the whole list does NOT need to be held in memory. So it's actually possible to run 30! permutations without causing a memory overflow.
Source: O'Reilly PHP Cookbook
License: http://opensource.org/licenses/BSD-3-Clause This software is a derived product, based on: Simple Machines Forum (SMF) copyright: 2011 Simple Machines (http://www.simplemachines.org) license: BSD, See included LICENSE.TXT for terms and conditions.
Located at sources/Subs.php
Return value summary
||the next permutation of the passed array $p|