How do I put these: @{$subset}, [@ext_subset], [$last_item] in PHP?
- by Alex
I'm having trouble translating a subroutine from Perl to PHP (I'm new to Perl).
The entire subroutine is as follows:
sub find_all_subsets {
if (1 == scalar (@_)) {return [@_]}
else {
my @all_subsets = () ;
my $last_item = pop (@_) ;
my @first_subsets = find_all_subsets (@_) ;
foreach my $subset (@first_subsets) {
push (@all_subsets, $subset) ;
my @ext_subset = @{$subset} ;
push (@ext_subset, $last_item) ;
push (@all_subsets, [@ext_subset]) ;
}
push (@all_subsets, [$last_item]) ;
return (@all_subsets) ;
}
}
My problem is that I really don't quite understand the Perl syntax, so I'm having trouble writing these @{$subset}, [@ext_subset] and [$last_item] in PHP.
Thanks and sorry if the question is stupid.