To help you get started using it on your website or application, here is the sample function written in the C# language;
public static string getLimitedWords(string str,int NumberOfWords) {
string[] Words= str.Split(' ');
string _return=string.Empty;
if(Words.Length<=NumberOfWords)
{ _return = str; }
else
{ for(int i=0;i<NumberOfWords;i++)
{ _return+=Words.GetValue(i).ToString()+" "; }
}
return _return.ToString();}
As you can see from this code above, we first take str and split it based on empty spaces. We then move the string into an array Words. Finally, we then use "for loop" to take however number of words we want. For example if the array Words have 10 items, we can pull 0 to 4 items if we want to show first five words from the long string. This can be helpful whenever or wherever we do not want to cut out any words, but do not show a long string.