[PHP-users 9328] Re: $BG[Ns$K$D$$$F(B
HIGASHI Taku
php-users@php.gr.jp
Fri, 16 Aug 2002 14:18:28 +0900 (JST)
From: "Tatsuya Kondo" <konet@zc.wakwak.com>
Subject: [PHP-users 9322] $BG[Ns$K$D$$$F(B
Date: Fri, 16 Aug 2002 13:06:23 +0900
Message-ID: <000901c244da$4c06ab60$3201a8c0@tatsuya>
konet> $aa[0]$B!"(B$aa[1]$B!"(B$aa[2]$B!"(B$aa[3]
konet> $B$J$I$NG[Ns$N!"AH$_9g$o$;$rA4$F<hF@$9$kJ}K!$G$9!#(B
$B:F5"$H;HMQ:Q$_MWAG$N:o=|$,%]%$%s%H$G$9$M!#(B
--
#! /usr/local/bin/php
<?php
$a = array( "A", "B", "C", "D" );
for ($num = 1; $num <= count($a); $num++) {
partOf($a, $num);
}
exit;
function partOf($a, $num, $part = "") {
for ($i = 0; $i < count($a); $i++) {
$newPart = $part . $a[$i];
$b = $a; // $BG[Ns$r%3%T!<(B
array_splice($b, $i, 1); // $part$B$KBeF~:Q$_$NMWAG$r:o=|(B
if ($num > 1 && count($b) > 0) {
partOf($b, $num - 1, $newPart);
} else {
print $newPart . "\n";
}
}
}
?>
--