Created
October 13, 2015 21:38
-
-
Save patrickgilmour/db6c8ae09560d67c0852 to your computer and use it in GitHub Desktop.
Truncates a string to the nearest defined word boundary.
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 | |
// Truncates a string to 275 characters to the nearest word | |
// from: preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, 201)); | |
$the_substring = preg_replace('/\s+?(\S+)?$/', '', substr( $the_string , 0, 275)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment