FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » cut body in search page
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
cut body in search page [message #5330] Tue, 27 August 2002 21:26
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user

it fit chinese like language

when the $body content have both chinese and english

if( strlen($body) > 80 ) $body = substr($body,0,80).'...';

sometimes ,it will cut one chinese word to two part

eg:
$body="aaaaa中(it is a chinese word)";
$body = substr($body,0,6);

i use the the code to fit it
=================================

function ChgTitle($title,$length) 
{ 
if (strlen($title)>$length) { 
$temp = 0;
for($i=0; $i<$length; $i++) {
if (ord($title[$i]) > 128) {//whether or not a chinese word
$temp++; 
}
}
if ($temp%2 == 0) {
$title = substr($title,0,$length)."..."; 
}else{ 
$title = substr($title,0,$length+1)."...";
}
} 
return $title; 
} 

=================================

eg:
===============
$body=ChgTitle($body,80);
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Current Time
Next Topic: Adding forums to pre-existing search engine
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Oct 19 03:30:19 EDT 2017

Total time taken to generate the page: 0.00629 seconds