Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

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

Colin Viebrock skrev:

> function showCombinations($array) {
> $num = count($array);
> for ($i=1; $i<pow(2,$num); $i++) {
> for ($j=0; $j<$num; $j++) {
> if ( pow(2,$j) & $i ) {
> echo $array[$j] . "\t";
> }
> }
> echo "\n";
> }
> }
>
> $array = array("apples","bananas","cantaloupe","dates");
> showCombinations($array);

  Wow! That's so cool! Thank's a million.

Regards,

Erik Tjernlund
Stockholm

--
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>