Skip to content

Instantly share code, notes, and snippets.

@jackmcdade
Created January 16, 2015 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackmcdade/4ab043acb25737b630c9 to your computer and use it in GitHub Desktop.
Save jackmcdade/4ab043acb25737b630c9 to your computer and use it in GitHub Desktop.
Workaround for truncate ellipsis
<?php
/**
* Modifier_truncate
* Truncates the value of a variable
*
* @author Jack McDade
* @author Fred LeBlanc
* @author Mubashar Iqbal
*/
class Modifier_actually_truncate extends Modifier
{
public function index($value, $parameters=array()) {
$length = array_get($parameters, 0, 30);
if (strlen($value) > $length) {
return substr($value, 0, $length);
}
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment