Buy Sell Discuss UK Domain Names at AcornDomains.co.uk

Today's drop dates are 15-08-2008 & 22-08-2008  
Domain Name Sales Domain Software Calculate UK Domain Drop Dates Domain Lists SedoPro Code Domains For Sale NameDrive Domain Parking
Go Back   Domain Name Forum Acorn Domains Buy Sell Trade UK Domain Names > Website Design and Promotion > Website Design

Website Design Discuss webmastering issues or ideas to help you design websites to make the most of your domain portfolio

Reply
 
Thread Tools Display Modes
Old 20-11-2006, 11:13 AM   #1

 
grantw's Avatar
 
Join Date: Mar 2005
Posts: 1,861
grantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond repute

PHP help

Can any PHP geniuses help me out here, here is what I want to do:

if length of $string > 50 then $string = first 50 characters + "....."


Thanking you kindly

Grant
__________________
Domain Brokerage :: Credit Report :: Domain Chat :: York Yoga
grantw is offline   Reply With Quote
Old 20-11-2006, 11:32 AM   #2

 
Join Date: May 2006
Posts: 940
Jeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond repute

$string = (strlen($string)>50) ? substr($string,0,50).'…' : $string;

Jee
Jeewhizz is offline   Reply With Quote
Old 20-11-2006, 12:21 PM   #3

 
Join Date: Jan 2005
Posts: 160
mishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond reputemishmash has a reputation beyond repute

If you're creating an excerpt then that'll sometimes cut you off in the middle of words.

You can avoid this by trimming the output of the above and removing anything between the last word boundary and the end of the string.

Code:
$string = preg_replace('/\b.*$/', '', $string);
Even smarter excerpts can be created by looking for whole sentences. Though with only 50 characters you probably won't get many of them.
mishmash is offline   Reply With Quote
Old 20-11-2006, 12:56 PM   #4

 
grantw's Avatar
 
Join Date: Mar 2005
Posts: 1,861
grantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond repute

Thanks for the assistance chaps, very helpful and much appreciated.

Grant
__________________
Domain Brokerage :: Credit Report :: Domain Chat :: York Yoga
grantw is offline   Reply With Quote
Reply



Bookmarks

Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Domain Name Community Replies Last Post
PHP Web Developer in need of work bboystu Scripts and Coding 3 31-07-2008 10:17 AM
SSI or PHP include? purg Search Engine Optimisation 4 10-11-2006 09:44 PM
PHP Link Directory - Free Templates admin Website Design 0 18-05-2006 01:25 PM
PHP Coders? storebuilder Website Design 10 23-02-2006 12:24 PM


All times are GMT +1. The time now is 12:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85