/** * trims text to a space then adds ellipses if desired * @param string $input text to trim * @param int $length in characters to trim to * @param bool $ellipses if ellipses (...) are to be added * @param bool $strip_html if html tags are to be stripped * @return string */ function trim_text($input, $length, $ellipses = true, $strip_html = true) { //strip tags, if desired if ($strip_html) { $input = strip_tags($input); } //no need to trim, already shorter than trim length if (strlen($input) <= $length) { return $input; } //find last space within length $last_space = strrpos(substr($input, 0, $length), ' '); $trimmed_text = substr($input, 0, $last_space); //add ellipses (...) if ($ellipses) { $trimmed_text .= '...'; } return $trimmed_text; } function sluggify($url) { # Prep string with some basic normalization $url = strtolower($url); $url = strip_tags($url); $url = stripslashes($url); $url = html_entity_decode($url); # Remove quotes (can't, etc.) $url = str_replace('\'', '', $url); # Replace non-alpha numeric with hyphens $match = '/[^a-z0-9]+/'; $replace = '-'; $url = preg_replace($match, $replace, $url); $url = trim($url, '-'); return $url; } ?>
Posted on Feb 26 2018
We provide New York Shuttle Transportation to and from virtually anywhere in the New York area! We go to Manhattan, Brooklyn, Queens, The Bronx, and even Staten Island! Contact us today for more information and get started on your next trip with us.
Share on Social Media
Tags: Things to do in New York