Home>Article>Backend Development> PHP method to automatically generate numbers based on data ID
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!