PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,455 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,596 people online right now. Registration is fast and FREE... Join Now!




Is there a function for calculating the dimension (not length) of a st

 

Is there a function for calculating the dimension (not length) of a st

livium

2 Jul, 2009 - 09:44 AM
Post #1

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
Is there a function for calculating the dimension (not length) of a string? Because the dimension of 'a' is bigger than that of 'l'. I need such a function very baddly because i wanna calculate the number of spaces that i must put between two strings that are put in a fixed div, so that the first string is align to the left of the div and the other is align to the right of it.
So... is there such a function?

User is offlineProfile CardPM
+Quote Post


Dantheman

RE: Is There A Function For Calculating The Dimension (not Length) Of A St

2 Jul, 2009 - 10:12 AM
Post #2

D.I.C Regular
***

Joined: 27 May, 2009
Posts: 445



Thanked: 25 times
My Contributions
Functions deal with the string data. The dimension is not a string data. It's a font-dependent, screen-dependent, platform-dependent, monitor-dependent .... attribute.

Use a monospaced font, then every character will have the same dimension.
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Is There A Function For Calculating The Dimension (not Length) Of A St

2 Jul, 2009 - 10:18 AM
Post #3

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
If you use CSS pt (points) instead of px (pixels) for positioning, it's supposed to make it easier to work with situations like this.

I don't really believe it, but hey.

You could also make your own function, store widths of characters in an array, loop through the string, and add up all the widths.
User is offlineProfile CardPM
+Quote Post

livium

RE: Is There A Function For Calculating The Dimension (not Length) Of A St

2 Jul, 2009 - 10:22 AM
Post #4

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
Thanks. I will use a monospace then.

QUOTE(MageUK @ 2 Jul, 2009 - 10:18 AM) *

If you use CSS pt (points) instead of px (pixels) for positioning, it's supposed to make it easier to work with situations like this.

I don't really believe it, but hey.

You could also make your own function, store widths of characters in an array, loop through the string, and add up all the widths.



thanks, but that's to hard to do. I'll try using monospace.
User is offlineProfile CardPM
+Quote Post

CTphpnwb

RE: Is There A Function For Calculating The Dimension (not Length) Of A St

2 Jul, 2009 - 10:28 AM
Post #5

D.I.C Lover
Group Icon

Joined: 8 Aug, 2008
Posts: 2,065



Thanked: 151 times
Dream Kudos: 100
Expert In: PHP

My Contributions
What's wrong with using text-align?
http://htmlhelp.com/reference/css/text/text-align.html
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:57AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month