By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Shortening a fetched array

P: 2
Hi, i'm unsure of the versions of MySQL and PHP I'm using (although my webhost 'guarantees' the latest), but I don't think the answer would vary that much between versions.
Now to the point:
I'm trying to echo text fetched from a database into a 128px width column, which doens't always fit. I'd like to know how to shorten the results of an array using '...'s like: 'Amer...' or 'Urag...' instead of 'America' or 'Uraguay'.

Thank you,
ViperBlade
Feb 24 '07 #1
Share this Question
Share on Google+
3 Replies


Motoma
Expert 2.5K+
P: 3,235
Hi, i'm unsure of the versions of MySQL and PHP I'm using (although my webhost 'guarantees' the latest), but I don't think the answer would vary that much between versions.
Now to the point:
I'm trying to echo text fetched from a database into a 128px width column, which doens't always fit. I'd like to know how to shorten the results of an array using '...'s like: 'Amer...' or 'Urag...' instead of 'America' or 'Uraguay'.

Thank you,
ViperBlade
Welcome to theScripts ViperBlade!
This task will be quite difficult unless you are using a monospaced font.
Feb 24 '07 #2

P: 2
Welcome to theScripts ViperBlade!
This task will be quite difficult unless you are using a monospaced font.
True, but i'll be using Lucidia Sans Console. Do you have any ideas? I know it's
possible because phpMyAdmin shortens certain fields with '...'s.

Thanks for the welcome,
ViperBlade
Feb 24 '07 #3

Motoma
Expert 2.5K+
P: 3,235
True, but i'll be using Lucidia Sans Console. Do you have any ideas? I know it's
possible because phpMyAdmin shortens certain fields with '...'s.

Thanks for the welcome,
ViperBlade
In order to fit it correctly inside a certain pixel width, you would have to calculate the width of each character, and the truncate the string, and append "..."
Feb 24 '07 #4

Post your reply

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