Try using simple descriptions and then capitalize. BigRedCars, SmallBlueCar, LeafyElmTree, WiltingFlower, BloomingFlower.
You could ust name a few replace statements in a separate file(titletrimmer.php) and then
PHP Code:
<title><?php if ($title > 34){ include('titletrimmer.php'); }ELSE{ echo $title;};?></title> $title='My large title with lots of large words';//35 charactors str_ireplace('$array1','$array2',$title);//array2[0] replaces array1[0] //this will replace all strings matching 'common words' I would try of, the, at, in, a $caps=ucword($title);//capitalize first letter of each word $title=str_replace(' ','',$caps);//replaces all spaces with no space notice no ireplace just replace $title=substr($do,0,34);//trims to 34 if it is higher echo $title;
MyBigTitleBigWords //18 charactors
That should work since a text string is converted into a numerical value when you use a mathematical comparator like, greater than. I hope that helps. if not you might try converting words into chat shorthand.
str_ireplace('eight,ate','8',$title); You can use arrays for the first two values. If the first array(search for) is longer than the second array(replace with) a blank value will be used. You must use str_ireplace before ucwords() and str_replace(). This is because str_ireplace() converts all text to lowercase then searches for matching string.
http://www.php.net/manual/en/function.str-ireplace.php
Last edited by Skorch : 10-14-2005 at 01:57 AM.
|