Reply
Cleaning up text...
Old 10-04-2005, 10:42 PM Cleaning up text...
Brian07002's Avatar
Super Spam Talker

Posts: 869
Name: ...
Location: ...
Hi,

Does anyone know of an easy way to clean up descriptions? Better yet, this is a title issue that I have...Meaning the titles are inside an sql database table in which I can change the length of, but that will also change the layout of my homepage because the titles are displayed in table where if the length is greater than 34 characters in length, the title will wrap to the next line. I don't want wrapping to take place. So basically I want to make it so that the title text is 34 characters or less, but I want it to be 'understandable'...Meaning the title is also the 'alt' text for the thumbnails, so I want the title to be as descriptive as possible without loosing any words or if it needs to be cut short, (keeping in mind not less than 34 characters due to the table the title get's placed in) still readable...

Here would be an example: ( Note all text is different )

Description:
Quote:
Large Painting Of A Bird In The Wilderness
I want to cut the above description to no more than 34 characters in length so the above description would be:

Quote:
Large Painting Of A Bird In The Wi
Note: That includes the spaces as well.

How could that description (when cut down to 34 characters or less) still be made in 'English'? Meaning I guess the point to this whole post would be that I want to make the title field in my database cut short to no more than 34 characters in lenght, BUT the title MUST make sense. Not cut short. Is there an easy way to do that? Without having to modify each title one by one.

HOPE YOU UNDERSTAND WHAT I AM TRYING TO GET AT.

Thank you in advance!
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 10-05-2005, 12:37 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
If you're using PHP, just do something like this:

PHP Code:
<?php echo substr($row['title'], 034); ?>
__________________
Free Teacher Websites
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 10-05-2005, 03:17 AM
chrishirst's Avatar
Super Moderator

Posts: 16,477
Location: Blackpool. UK
Given these parameters
Quote:
so I want the title to be as descriptive as possible without loosing any words or if it needs to be cut short, (keeping in mind not less than 34 characters due to the table the title get's placed in) still readable...
Quote:
How could that description (when cut down to 34 characters or less) still be made in 'English'? Meaning I guess the point to this whole post would be that I want to make the title field in my database cut short to no more than 34 characters in lenght, BUT the title MUST make sense. Not cut short. Is there an easy way to do that? Without having to modify each title one by one.
No!

I mean how can you shorten something with either loosing words. You either cut off the ends, or cut out a mid section. Either way it probably won't make sense.
Unless you want to create a AI engine that understands language constructs, semantics and syntax it won't be happening
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-05-2005, 05:20 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
You could cut out common words such as 'a' 'in' the' 'of' 'or' etc. It wouldn't guarentee it to be less than 34 characters and it might not make total sense. But the key words will still be there.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"
Inoxia Pyrotechnics Supplies | Surrey Angels Cheerleading Squad
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 10-14-2005, 01:29 AM
Skorch's Avatar
Super Talker

Posts: 115
Location: California
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
__________________
Check out my Cliff Diving website!

Last edited by Skorch : 10-14-2005 at 01:57 AM.
Skorch is offline
Reply With Quote
View Public Profile Visit Skorch's homepage!
 
Reply     « Reply to Cleaning up text...
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13784 seconds with 12 queries