ho questa funzione che tronca un testo a tot caratteri:

Codice PHP:
function trim_sentence($string$num)
{

    
$done 0;
    
$letters 0;
    
$sentence '';

//echo $string;
    
$words explode(" "trim($string));
    
$totalwords count($words);
    for(
$i 0$i $totalwords$i++) {
        
$word_array preg_split('//'$words[$i], -1PREG_SPLIT_NO_EMPTY);
        
$letters $letters count($word_array);
        
        if ((
$letters $num) && ($done == 0)) {
            
$sentence trim($sentence) . "...";
            
$done 1;
        } 
        if (
$done == 0) {
            
$sentence .= $words[$i] . " ";
        } 
    } 
    return (
$sentence);

che viene richiamata ad es. così:
Codice PHP:
echo trim_sentence($sentence_text20); 
Vorrei che nel caso nel testo ci sia un (o più) link questi vengano ignorati dal conteggio dei caratteri.
Cioè vorrei che se c'è:
testo testo testo testo <a href=www.cicca.it>guarda qui</a> testo testo testo testo

vengano contati solo:
testo testo testo testo guarda qui testo testo testo testo

spero di essere stato chiaro...