xxxxxxxxxx
$words = "Hello Coders ! vote on grepper";
$output = substr($words, 0, 10);
xxxxxxxxxx
function truncate($str, $width) {
return strtok(wordwrap($str, $width, "...\n"), "\n");
}
print truncate("This is very long string with many chars.", 25);
# This is very long string...