Forum Moderators: coopster

Message Too Old, No Replies

Splitting long strings

         

dkin

6:04 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



anyone know how to split a string if it is over say 25 characters? Im sooo tired, running on 3 hours sleep.

Thanks all

jatar_k

6:44 pm on Aug 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what do you want to split it into?

if strlen > 25
do what?

substr to 25 chars?

dkin

7:14 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



I just want to add a line break so I figure split it into 2 variables then I can add \n or <br> in between.

dkin

7:19 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



of course I would want to split it by spaces so say I have this.

"I love blue and red widgets"

would be

"I love blue and red
widgets"

coopster

7:33 pm on Aug 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Will wordwrap [php.net] work?

dkin

9:36 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



yes actually, it seems to work beautifully, thank you.