Home>Article>Backend Development> PHP method to automatically generate numbers based on data ID

PHP method to automatically generate numbers based on data ID

墨辰丷
墨辰丷 Original
2018-05-31 16:40:13 3601browse

This article mainly introduces the method of automatically generating numbers based on data ID in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

is as follows:

/*编号=年份后两位+月份+id四位数*/ $id = $this->student_model->save(0, $data); $sn = date('Y', time()); $sn = substr($sn, -2); $sn.= date('m', time()); $sn.=sprintf("%04d", $id);

[Result Preview] Example: 14120001

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

phpSteps to upgrade the MySQL version to 5.7.17 in Study

PHP custom function to determine whether it is a method submitted by Get, Post and Ajax

##phpUsage analysis of bind_param() function

The above is the detailed content of PHP method to automatically generate numbers based on data ID. For more information, please follow other related articles on 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