Skip to content

Instantly share code, notes, and snippets.

@KruegerDesigns
Last active January 2, 2016 20:59
Show Gist options
  • Save KruegerDesigns/8360175 to your computer and use it in GitHub Desktop.
Save KruegerDesigns/8360175 to your computer and use it in GitHub Desktop.
<?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