if( length($string) > 50 ) { # cut the string and either add ... to show it was truncated. $string = substr( $string, 0, 47 ) . '...'; # alternatively, or not $string = substr( $string, 0, 50 ); }