You might want to look at wordwrap to help you with your problem.
Otherwise, i would say. Turn your string into an array of words, loop through and check the strlen() of each word. Of course, you then need to decide what your going to do when you find a word bigger than you want.