Jump to content

Increment with leading zeros


xcandiottix

Recommended Posts

I have a db with entries as follows:

 

A001

A002

A003

 

I would like to loop thru these and print them on screen. Instead of doing:

 

echo A001

echo A002

echo A003

 

I'd like to find a better way since this database will scale up in the future and may get to A999.

 

Is there a way to increment with leading placeholder zeros?

for($x=0 ; $x < mysql_num_rows($myresult) ; $x++){
echo $row['A'.##increment here##'];
}

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/214064-increment-with-leading-zeros/
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.