Jquery and PHP function

Posted by Sergio on Stack Overflow See other posts from Stack Overflow or by Sergio
Published on 2010-04-06T10:38:57Z Indexed on 2010/04/06 10:43 UTC
Read the original article Hit count: 328

Filed under:
|

How can I this PHP function include in jquery .html?

PHP function:

function trim_text($string, $limit, $break="<", $pad=" ...")
{
$words = explode(' ', htmlentities(strip_tags($string)));
$countr = count($words);
if ($countr <= 8)
{
return $string;
}else{


// return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string;
$string = substr($string, 0, $limit);
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
if($breakpoint < strlen($string) - 1) {

  $string = substr($string, 0, $breakpoint) . $pad;
}
}
$last_space = strrpos(substr($string, 0, $limit), ' ');
$string = substr($string, 0, $last_space);
$string = strip_tags($string);  
return $string.$pad;
}
}

And the Jquery part of code where I want to in ".html" part somehow call this function is:

$(" .text").html('<div>'+ message +'</div>');

What I want to do is trim this "message" text using PHP function. Is it possible?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php