Howto quwestion..!!! [newbie]

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
sWO0p
Forum Newbie
Posts: 2
Joined: Sun Oct 06, 2002 9:55 am

Howto quwestion..!!! [newbie]

Post by sWO0p »

hi,

first i have to say cool site, learn alot here...

okay now to question..

i'm currently working on my php skills and have to say i'm getting rather good at it.. im constructing a status network page and have a little problem

i use a news headline ripper to get a few lines on new news from a local site, there posted in a tabel but this tabel can not expand in height or width...

now i'm search a script or a way to cut of the end of the news headline and replace it with dots so it wil fit into my tabel without expanding....
in this tabel i can have a 35 to 40 caracters...

can someone helpme?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have a look at the substr() function.

Mac
sWO0p
Forum Newbie
Posts: 2
Joined: Sun Oct 06, 2002 9:55 am

Post by sWO0p »

Thanx for the hint...

found a neet little code and it works, had to rearange a little but it works fine...

Code: Select all

/// it breaks at the end of a word ///

$maxTextLenght=125; /// caracters but keep in minde the url has caracters to ////
$aspace=" ";
if(strlen($text) > $maxTextLenght ) {
$text = substr(trim($text),0,$maxTextLenght); 
$text = substr($text,0,strlen($text)-strpos(strrev($text),$aspace));
$text = $text.'...';
}
  echo "$text"; /// if you (like me) have a list of urls use this 2nd echo to break line and kill <a href>///
  echo "</a><br>"; 
&#125;
Credits go to Senty to....! thx man
Post Reply