Home  >  Article  >  Backend Development  >  php 改数字 例如10000变成1万

php 改数字 例如10000变成1万

WBOY
WBOYOriginal
2016-06-23 14:23:591833browse

当数值大于等于10000的时候输出1万  小于10000正常输出
15000输出1.5万
100000输出10万

要怎么写


回复讨论(解决方案)

$i=15000;echo $i>=10000 ? $i/10000 .'万' : $i;

$i=15000;echo $i>=10000 ? $i/10000 .'万' : $i;

+1

动态语言做这种事情太合适了

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