Hello Reader's If you want to get all elements in the combinations then you can use PHP code to generate it.
Lets see the example as below:-
function pc_permute($items, $perms = array()) {
if (empty($items)) {
echo join(' ', $perms) . "<br />";
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
$newitems = $items;
$newperms = $perms;
list($foo) = array_splice($newitems, $i, 1);
array_unshift($newperms, $foo);
pc_permute($newitems, $newperms);
}
}
}
The array is:-
$arr = array('peter', 'paul', 'mary');
pc_permute($arr);
Output:-
peter-paul-mary
peter-mary-paul
paul-peter-mary
paul-mary-peter
mary-peter-paul
mary-paul-peter
0 Comment(s)