I develop this function to short the string without cutting the words. As we now that PHP’s substr() function only provide the part of the string, substr() function provide the string between the two parameters, start from and end to.
So I need a function that provide the string arround the given starting from and end to range. Below given function provide the arround complete word from the string. This function check the nearest space into the string and provide the nearest word without cutting. If you guys have a better alternative then please feel free to share the codes in the comment section.