开发者

How to get the first two numbers in an integral?

开发者 https://www.devze.com 2022-12-30 12:56 出处:网络
How to get the first two 开发者_Python百科numbers in an integral? For example: get 12 of the 123456 in PHP or JavaScript?PHP:

How to get the first two 开发者_Python百科numbers in an integral?

For example: get 12 of the 123456 in PHP or JavaScript?


PHP:

$num = 123456;
echo substr($num, 0, 2);

JavaScript:

alert((123456).toString().substr(0, 2));


JavaScript:

(123456).toString().substr(0,2);

PHP:

substr(123456, 0, 2);


$result = substr("123456", 0, 2);


Numerically in Javascript:

while (number >= 100) number = Math.floor(number / 10);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号