Reputation: 10261
i am using substr to trim the first 100 characters from the string. however i need a function that can trim a particular number of words, instead of characters from a string?
$trimmed_details = substr($row->details, 0, 200).'...';
is there a built in function to do that?
Upvotes: 0
Views: 179
Reputation: 157863
No, there is no builtin function in both PHP and mysql. Because there is no data type "word (of language)" in the either system. You can invent some regexp to do this, but I'd avise to just give up and use old char-based trimming.
Upvotes: 1