这似乎微不足道,但我感到困惑的是,我无法就此达成解决方案.我想要做的是:
Input -> 14025
Output -> 10245
Input -> 171
Output -> 117
Run Code Online (Sandbox Code Playgroud)
等等...
$input = 140205;
$temp = str_split($input);
sort($temp);
// find the 1st non-zero digit
$f = current(array_filter($temp));
// remove it from the array
unset($temp[array_search($f, $temp)]);
echo $output = $f . join($temp); // 100245
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42 次 |
| 最近记录: |