Last active
January 2, 2016 20:59
-
-
Save KruegerDesigns/8360175 to your computer and use it in GitHub Desktop.
String character limiter, referrence: http://stackoverflow.com/questions/3161816/php-cut-a-string-after-x-characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Referrence: http://stackoverflow.com/questions/3161816/php-cut-a-string-after-x-characters | |
// Max allowed characters | |
$limit_max = 160; | |
// If limit exeeded, remove 3 characters to make room for trail | |
$limit_trail = $limit_max - 3; | |
$string = (strlen(string) > $limit_max) ? substr($string,0,$limit_trail).'...' : $string; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment