only1perky Posted September 10, 2008 Share Posted September 10, 2008 Hi guys, I've run into a problem which I just cannot figure out. I have a field which users type a description of their business in. This works fine. On my home page I display a featured business which will show their name, email and description etc. What I need help doing is limiting how many words from the description are displayed on the home page. For example if the description is only 20 words it would display them all but If there are 200 words it would display the first 20 then ... Can anyone supply the code for me to achieve this? Any help would be greatly appreciated. Cheers in advance. Quote Link to comment https://forums.phpfreaks.com/topic/123634-how-do-i-limit-the-number-of-words-displayed/ Share on other sites More sharing options...
Maq Posted September 10, 2008 Share Posted September 10, 2008 Yes, you can explode the string with the delimiter being a space (" "). Then loop to 20 storing these words into another string then display the new string in the description. Quote Link to comment https://forums.phpfreaks.com/topic/123634-how-do-i-limit-the-number-of-words-displayed/#findComment-638431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.