(1) enter a number string to find the maximum number. For example, enter 17893 and the maximum number is 9. (2) sort the five numbers... For example, in the preceding example, the result is 98731;
(1) enter a number string to find the maximum number. For example, enter 17893, and the maximum number is 9;
(2) sort these five numbers... For example, in the preceding example, the result is 98731;
$ Num = "17892"; // initial value. you can use $ _ POST [] to obtain the value submitted by the form.
$ Len = strlen ($ num); // get the length
$ Tmp = ""; // initialize $ tmp
/* Use-to split $ num as follows */
For ($ I = 0; $ I <$ len; $ I ++ ){
$ Tmp. = substr ($ num, $ I, 1 ).'-';
}
$ Arr = explode ('-', $ tmp); // generates an array
Rsort ($ arr); // descending order
Echo $ arr [0].'
'; // Maximum output value
Echo implode ($ arr, ''); // output the new value in descending order.
?>