Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

[PHP3] How to get all possible permutations from an array in PHP? From: Erik Tjernlund (erik <email protected>)
Date: 01/23/99

Hi all,

  I have a classic CompSci-problem tonight. I wrote this algorithm
in a class last year (in Scheme), but now I just can't figure it out.
I need a PHP-function that takes an array as input and returns all
possible permutations. I'm writing a searchengine for my personal
webpages and it would be great to be able to show partial matches
instead of just a "perfect 100%" hit.

  If the array was [A,B,C] my result should be:

        [A,B,C]
        [A,B]
        [A,C]
        [B,C]
        [A]

The order of the elements doesn't matter. I have searched
the "usual" PHP-algorithm-archives, but to no avail. Has
someone out there already written this and could show me
how?

Yours Sincerely,

Erik Tjernlund <erik <email protected>>
Royal Institute of Technology
Stockholm, Sweden

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3
List administrator:  zeev-list-admin <email protected>