如何格式化会计代码[关闭]

I would like to display the accounting account code using php from 12345678 to form 123.45.678, is there any one can help me ? Thank you

you can use a regex for this with preg_replace (for a 8 character digit as in your example) in your php code

$number = 12345678;

echo "Number is: ${number}";
$new_number=preg_replace('/(\d{3})(\d{2})(\d{3})/','$1.$2.$3', $number);

echo "Number is: ${new_number}";

I wrote this up quickly and it seems to provide the functionality you wanted:

https://jsfiddle.net/tdaeunem/

function splitNumber(inputNumber){

    var firstPart = /^(\d{3})/;
    var secondPart = /^\d{3}(\d{2})/;
    var thirdPart = /^\d{5}(\d{3})/;

    var matches = [];

    matches[0] = inputNumber.match(firstPart)[1];

    matches[1] = inputNumber.match(secondPart)[1];

    matches[2] = inputNumber.match(thirdPart)[1];

    return matches.join(".");

}

console.log(splitNumber("12345678"));