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 :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
cut body in search page [message #5330] Wed, 28 August 2002 01:26
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

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);
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sat May 18 13:51:09 GMT 2024

Total time taken to generate the page: 0.02494 seconds