Truncate string to closest word to specified length

Doesn't break words when truncating strings. Read more.

php
fork add to bundle source
function shorten_string_to_words($string, $length) { return substr($string, 0, strpos(wordwrap($string, $length), "\n")); }

usage

load_function('shorten_string_to_words'); echo shorten_string_to_words('Codes went live.', 9); // Codes went
← how to use this in app?
create log ...inout