473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Pack() function but padd spaces on left instead of right (align right)

dlite922
1,584 Expert 1GB
I'm building a monospaced text output and it works fine with pack("A23",$variable) for example that makes sure the variable valuse takes up 23 spaces. If the string is less than 23, it fills the rest with spaces.

BUT

now i have dollar amount which of course want to align right (pad the spaces on the left)

any ideas?
May 21 '08 #1
3 1780
dlite922
1,584 Expert 1GB
I'm building a monospaced text output and it works fine with pack("A23",$variable) for example that makes sure the variable valuse takes up 23 spaces. If the string is less than 23, it fills the rest with spaces.

BUT

now i have dollar amount which of course want to align right (pad the spaces on the left)

any ideas?
Nevermind, found str_pad(). I don't think what i need can be done with pack().

Can't believe I forgot about that.

If anybody is curious its str_pad($variableStr, 30, " ", STR_PAD_LEFT);

or STD_PAD_RIGHT for left-aligned text.

Thanks...to me i guess


Dan
May 21 '08 #2
Markus
6,050 Expert 4TB
Nevermind, found str_pad(). I don't think what i need can be done with pack().

Can't believe I forgot about that.

If anybody is curious its str_pad($variableStr, 30, " ", STR_PAD_LEFT);

or STD_PAD_RIGHT for left-aligned text.

Thanks...to me i guess


Dan
You're welcome.

I hate the text limit being 20 characters.

Truly hate it.
May 21 '08 #3
dlite922
1,584 Expert 1GB
You're welcome.
.
Heeeey!! You're not me!

:P
May 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rookie | last post by:
I need to display several columns of numbers in a textbox. I wish to display the columns with the decimal point position aligned vertically. I have found that the # digit placeholders do not...
0
by: BW | last post by:
Please ignore the rest of the code, except for the highlighted part (or the line 'ent1=Entry(topf, width=25)' to line 'ent1.insert(INSERT, wrong, if you cannot see the color). You can copy this into...
6
by: TJ | last post by:
I've got a calendar that is based on the concept of lots of blocks that are spans with float:left. I would like to be able to have a detail section on the right side of the screen, so that when...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.