Home  >  Article  >  Backend Development  >  php 数字格式化输出

php 数字格式化输出

WBOY
WBOYOriginal
2016-06-23 13:15:002216browse

往往是对于一些订单编号我们需要对数据库取出的编号进行格式化,比如在前面补0等等,

下面介绍的是php格式化输出编号的方法

$var = sprintf("%06d",22);

得到的结果是000022

6指定位数~

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