Jump to content

int padding not working out


Ryoku

Recommended Posts

Coming hot off the heels of the last post I made is a branched problem. I have my file uploading working currently. It renames and posts correctly however the formatting is incorrect.

 

I have my formatting set up so that it is supposed to rename a file to the fallowing format

Date.postid.ext [date(Ymd).’-‘.$postid.$ext] which outputs 20080808-2.jpg

 

At first glance this looks correct however in my DB I want to have a padding to accommodate up to 10k  posts to accomplish that and maintain organization I want to pad the number with “0” until it has the correct number of characters. (so an example of correct formatting would be 20080808-00002.jpg)

 

Every time I have asked this people say to use the str_pad() function however I can’t seem to get it to work because when i echo it the string becomes an int and i lose my padding again. I know I'm probably doing it wrong.

 

Can someone give me an example of how to work with integer padding?

 

Link to comment
https://forums.phpfreaks.com/topic/120653-int-padding-not-working-out/
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.