this is the most easiest way- <? $var = "The quick brown fox jumps over the lazy dog"; echo substr($var,0,13); ?> PHP: this will show the first 13 charecter of the text (including Space) result is The quick bro Code (markup): but i want The quick bro... Code (markup): i mean adding some ... after trimming (& no ... if not trimmed) help me plz
this should do it <?php $var = "The quick brown fox jumps over the lazy dog"; $len = strlen($var); if($len > 13) { $var = substr($var,0,13); echo "$var ..."; } else { echo "$var"; } ?> PHP: -John
<?php $var = 'The quick brown fox jumps over the lazy dog'; $abbrv = strlen($var)>13 ? substr($var,0,13).'...' : $var; echo $abbrv; ?> PHP: If you wanted a condensed solution...