Last active
May 23, 2016 09:49
-
-
Save phucdohong96/7e9020911aea2052e4187e843f5ab320 to your computer and use it in GitHub Desktop.
Hàm thêm dấu chấm (.) vào một chuỗi số hàng ngàn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function adddotstring($strNum) { | |
| $len = strlen($strNum); | |
| $counter = 3; | |
| $result = ""; | |
| while ($len - $counter >= 0) | |
| { | |
| $con = substr($strNum, $len - $counter , 3); | |
| $result = '.'.$con.$result; | |
| $counter+= 3; | |
| } | |
| $con = substr($strNum, 0 , 3 - ($counter - $len) ); | |
| $result = $con.$result; | |
| if(substr($result,0,1)=='.'){ | |
| $result=substr($result,1,$len+1); | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment