Im trying to write algorithm to get all combinations and increment by one at a same time and get this
function generate($index){
$xxx = '';
$flag = 0;
$lengtchString = strlen($index);
for($y = 0; $y != $lengtchString; $y++) {
$xxx .= "$y";
}
while ($flag != $lengtchString )
{
for ($i = 0; $i<$lengtchString-1; $i++)
{
$temp = $xxx[$i];
$xxx[$i] = $xxx[$i+1];
$xxx[$i+1] = $temp;
echo $xxx."<br>";
}
$flag++;
}
}
generate('abc');
and output is
102
120
210
201
021
012
I need to get all combinations not only for 3
digits but also all combinations .
For example if I write 'abc
'... I need output like
102
120
210
201
021
012
256
874
569
236
254
028
and so on.... untill 789
in condition that digits wouldnt repeat...
my mind actually to be blown, cant get proper algorithm for that. thanks in advance