Jump to content

Number Increase


Canman2005

Recommended Posts

Hi all

 

I have a code which starts with a letter and then digits follow, an example code looks like

 

D002482

 

How can I get php to increase the codes number by 1, leaving the letter the same.

 

The above would look like

 

D002483

 

I tried

 

$codenum = substr('D002482', 1);
$codelet = substr('D002482', 0,1);
$code2 = $codenum+1;
print $codelet.$code2;

 

But that seems to remove the 00 at the start of the code

 

Can anyone help?

 

Thanks in advance

 

Dave

Link to comment
https://forums.phpfreaks.com/topic/61314-number-increase/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.