Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 10-04-2005, 10:42 PM Cleaning up text...
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
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
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-05-2005, 12:37 AM
Phaedrus's Avatar
Ultra Talker

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

PHP Code:
<?php echo substr($row['title'], 034); ?>
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 10-05-2005, 03:17 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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
Trades: 0
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!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 10-14-2005, 01:29 AM
Skorch1's Avatar
Super Talker

Posts: 115
Location: California
Trades: 0
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
Please login or register to view this content. Registration is FREE
website!

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.16190 seconds with 12 queries