PHP method to automatically generate numbers based on data ID

墨辰丷
Release: 2023-03-28 18:38:02
Original
3671 people have browsed it

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:

<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>
Copy after login

[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!

Related labels:
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