Need to shorten a result.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Adam
Forum Newbie
Posts: 11
Joined: Mon Jul 28, 2003 2:45 am

Need to shorten a result.

Post by Adam »

The problem is on the main page of my website at http://www.gamer-talk.net/. If you look in the reviews and previews box, the text is too long and makes it go 2 lines sometimes. I want to nake it so if it's too long, it will just go ...

i.e. Super Mario Advance 4: Super Mario Bros. 3 -> Super Mario Advance 4: Super Mario...

The code I have to display that is.

Code: Select all

<font class="<? echo "$platclass"; ?>"><? echo "$system"; ?>:</font> <a href="preview<? echo "$id"; ?>.html"><? echo "$name"; ?></a>
thanks for any help
User avatar
Fredix
Forum Contributor
Posts: 101
Joined: Fri Jul 18, 2003 2:16 pm
Location: Wehr (Eifel) Germany
Contact:

Post by Fredix »

Actually you approx. know how many characters fit into one line so you should take the sentence from the database and display eg. the first 20 caracters and then add "..."
Adam
Forum Newbie
Posts: 11
Joined: Mon Jul 28, 2003 2:45 am

Post by Adam »

I dont know how to code this... Can you or anyone help?
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

try to use substr


see details on http://www.php.net
Post Reply