Created
January 16, 2015 19:05
-
-
Save jackmcdade/4ab043acb25737b630c9 to your computer and use it in GitHub Desktop.
Workaround for truncate ellipsis
This file contains hidden or 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 | |
/** | |
* 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