Home  >  Article  >  php教程  >  Implementation method of php automatically generating numbers based on data ID

Implementation method of php automatically generating numbers based on data ID

高洛峰
高洛峰Original
2016-12-28 15:36:302713browse

As shown below:

<strong><span style="font-size:18px;">/*编号=年份后两位+月份+id四位数*/
  
$id = $this->student_model->save(0, $data);
$sn = date(&#39;Y&#39;, time());
$sn = substr($sn, -2);
$sn.= date(&#39;m&#39;, time());
$sn.=sprintf("%04d", $id);</span></strong>

[Result Preview] Example: 14120001

The above is the php basis that the editor has brought to you This is all about the implementation method of automatically generating numbers from data IDs. I hope everyone will support the PHP Chinese website~

For more articles related to the implementation methods of automatically generating numbers based on data IDs in PHP, please pay attention to the PHP Chinese website!

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