codice:function strSelect( $myString, $maxLength ) { // andr3a $out = ""; $s = explode( " ",$myString ); for( $i = 0, $cs = count( $s ); $i < $cs; $i++ ) { $out .= $s[$i]." "; if( isSet( $s[$i+1] ) && ( strlen( $out ) + strlen( $s[$i+1] ) ) > $maxLength ) { break; } } return rtrim( $out ); } echo strSelect("testo troppo lungo, decisamente troppo lungo",20);