Jump to content

Padding the length of a string, help! *SOLVED*


ecos

Recommended Posts

Hello,
I need help padding a string to a certain length, based on its existing length.  I need the string to have a length which is a multiple of 128.  If the string is 100 characters long, I need to pad with 28 characters to equal 128.  If the string is 208 characters, I need to pad it with 48 characters to equal 256, and so on for 384, 512, 640, ...

I know a bit about str_pad(), but I am not sure of a good way to know which multiple of 128 to bump the string length up to.

Thanks for any and all help!
Ecos
Link to comment
Share on other sites

phpORcaffine,
Thanks for the help. 
This is simialr to what I had come up with, but I needed something that could scale with any size string and any multiple of 128.
Initially I had a series of similar statements with each multiple, but that was extra clunky.

Thanks again,
Ecos 
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.