Created
April 11, 2019 02:58
-
-
Save ety001/b944e50000c3f5a3f4b8f0aa75e34040 to your computer and use it in GitHub Desktop.
元转换为分
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 | |
$a = [ | |
'123', | |
'1.2', | |
'1.23', | |
'1.234', | |
'1.2345', | |
// 用户出问题的数据 | |
'1.1', | |
'1.16', | |
]; | |
foreach($a as $v) { | |
var_dump($v); | |
} | |
echo "\n"; | |
foreach($a as $v) { | |
var_dump( (int)($v * 100) ); | |
} | |
echo "\n"; | |
foreach($a as $v) { | |
var_dump( ceil($v * 100) ); | |
} | |
echo "\n"; | |
foreach($a as $v) { | |
var_dump( number_format($v,2) * 100 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment