Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo trimmer("The quick brown fox was brown and quick.", 14, false);
- function trimmer($message, $K) {
- //trim last word recurisvely and compare to $K
- $pos = strrpos(trim($message) . " ", " ", -2);
- $trimmedString = substr($message, 0, $pos);
- if(strlen($trimmedString) > $K) {
- $trimmedString = trimmer($trimmedString, $K, true);
- return $trimmedString;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement