Page 1 of 1

Howto quwestion..!!! [newbie]

Posted: Sun Oct 06, 2002 9:55 am
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?

Posted: Sun Oct 06, 2002 10:06 am
by twigletmac
Have a look at the substr() function.

Mac

Posted: Sun Oct 06, 2002 12:43 pm
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