note 77783 deleted from function.substr by googleguy

From: Date: Tue, 16 Oct 2012 11:59:08 +0000
Subject: note 77783 deleted from function.substr by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191329@lists.php.net to get a copy of this message
Note Submitter: corphi ---- I prefer <?php function short_name($str, $limit) { return strlen($str) > $limit ? substr($str, 0, $limit - 3) . '...' : $str; } ?> Now, every returned string has a maximum length of $limit chars (instead of $limit + 3).

« previous php.notes (#191329) next »