gazever Posted July 18, 2007 Share Posted July 18, 2007 Ok, so after spending nearly all day on this problem, could someone please point me in the right direction. I am working on some scripts to format crossword clues etc. If I have a clue like the one below In which ocean was the Mary Celeste found abandoned and adrift? <8> I need to format this so there are a maximum of 18 characters per line, but not splitting any of the words, so I need to get it formatted like below In which ocean was the Mary Celeste found abandoned and adrift? <8> So only break it apart where there are spaces at the previous space before the 18th character, I need to put in a marker character where the line returns are put for part of my script further into it, so the completely formatted text will look like below, In which ocean was §the Mary Celeste §found abandoned §and adrift? <8> I need this script to work for all length clues which is why I'm getting in such a mess with it and going round in circles, Please help. Gaz Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 18, 2007 Share Posted July 18, 2007 You can use the wordwrap() function. http://php.net/wordwrap Quote Link to comment Share on other sites More sharing options...
gazever Posted July 18, 2007 Author Share Posted July 18, 2007 wow knew there would be a simple solution, Thanks Quote Link to comment 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.