Here's something - it's sloppy, but it works and has been tested for dupes:
Function derfunct($in, $count)
{
IF ($count>2)
$in=derfunct($in, $count-1);
global $r;
reset($r);
foreach($r as $k)
{
reset($in);
foreach($in as $v)
$return[]=$v.$k;
}
return $return;
}
$a='abcdef';
for ($i=0; $i<strlen($a); $i++)
$t[$a[$i]]=1;
reset($t);
$r=array_keys($t);
reset($r);
$out=derfunct ($r, strlen($a));
while (list($k, $v)=each($out))
echo "$k=$v\n";
// HOPE THIS HELPS... =)