Home  >  Article  >  Backend Development  >  php将一个整数拆成一个个个位数,然后再如图安放

php将一个整数拆成一个个个位数,然后再如图安放

WBOY
WBOYOriginal
2016-06-13 12:27:201001browse

php将一个整数拆成一个个个位数,然后再如图放置

数字是用php从后台提取的,就是不知道如何把这个数字拆开,好像只有先转为字符串形式。
------解决思路----------------------

$t = str_split(123456);<br />print_r($t);
Array<br />(<br />    [0] => 1<br />    [1] => 2<br />    [2] => 3<br />    [3] => 4<br />    [4] => 5<br />    [5] => 6<br />)<br /><br />

------解决思路----------------------
$num = 12345678;<br />$res = number_format($num);<br />echo $res;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn