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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.