Want to list recent news, display some of the content, but not all of it? Want to list all of your users but don't want to stretch your table with long usernames?
Well, this is a very simple way to shorten a variable if it exceeds the given length.
PHP Example :
<?php
$var = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // set variable
$varlength = strlen($var); // count number of characters
$limit = 10; // set character limit
if ($varlength > $limit) { // if character number if more than character limit
$var = substr($var,0,$limit) . "..."; // display string up to character limit, add dots