adrianmak Posted January 21, 2016 Share Posted January 21, 2016 Let says , return first 20 words of a paragraph 1 Link to comment Share on other sites More sharing options...
elabx Posted January 21, 2016 Share Posted January 21, 2016 How about substr? Link to comment Share on other sites More sharing options...
BitPoet Posted January 21, 2016 Share Posted January 21, 2016 /* Using regular expression */ $firstTwenty = trim(preg_replace('/^\s*((?:\S+\s+){20}).*/', '$1', $inputText)); /* Using split and combine */ $firstTwenty = implode(' ', array_slice(explode(' ', $inputText), 0, 20)); 2 Link to comment Share on other sites More sharing options...
mr-fan Posted January 21, 2016 Share Posted January 21, 2016 https://processwire.com/talk/topic/3429-how-to-set-text-linecharacter-limits-in-templates/#entry33748 regards mr-fan 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted September 27, 2016 Share Posted September 27, 2016 I can't remember where and if it is even true at all, but it seems to me I saw some helper functions in PW to do exactly that - summaries limited by words + ellipsis. Does anyone know what I am talking about? Link to comment Share on other sites More sharing options...
DaveP Posted September 27, 2016 Share Posted September 27, 2016 Ryan gave an example of how to do this in a blog post recently. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now