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

php 改数字 例如10000变成1万

WBOY
Release: 2016-06-23 14:23:59
Original
1869 people have browsed it

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

要怎么写


回复讨论(解决方案)

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

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

+1

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template