Jump to content

[SOLVED] splitting strings


gazever

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/60576-solved-splitting-strings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.