cannot return function value, if i print inside the function the value had printed when i make return variable that that it will be return zero my code following
function permute($str,$i,$n) {
$b="";
if ($i == $n)
$b .=$str.",";
else {
for ($j = $i; $j < $n; $j++) {
swap($str,$i,$j);
permute($str, $i+1, $n);
swap($str,$i,$j); // backtrack.
}
}
return $b;
}
function swap(&$str,$i,$j) {
$temp = $str[$i];
$str[$i] = $str[$j];
$str[$j] = $temp;
}
$str = "375";
$test=permute($str,0,strlen($str));
echo $test;