About amount conversion

key digital price conversion

how to put

0.10 to 0.01
10.10 to 10.01
20.50 to 20.05
30.10 to 30.01
1.52 to 1.25

is to change the position of wool and heel.

Oct.04,2021

    <?php
    function part_res($float) {
        if(!is_float($float)) {
            return false;
        }
        $part_res = explode('.', number_format($float, 2));
        if(!isset($part_res[1])) {
            return $float;
        }
        return $part_res[0] . '.' . strrev($part_res[1]);
    }
    
    var_dump(part_res(1.30));

simply use the regular (\.) (\ d) (\ d) = > $1 million 3 times 2
or you can use it first. Split numbers, separate them with empty strings, change positions, and then combine them back


the above answer is ok, but I didn't pay attention to the details:

'1.52'.replace(/(\d+)(\.)(\d)(\d)/g, ($1,$2,$3,$4,$5) => {return $2+$3+$5+$4})
Menu