Split long text string in half without breaking a word

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ramius
Forum Newbie
Posts: 1
Joined: Sun Sep 28, 2003 8:53 pm

Split long text string in half without breaking a word

Post by ramius »

Does anyone know how to split a long text string from say a forums program by a fraction i.e. half third etc. without breaking a word in half?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I can only think of [url=http://se.php.net/manual/en/function.wordwrap.php]wordwrap() but that is with simply using an existing function.

You can surely build something fun using str_pos() or similiar also.

You dont mention any reason for it, so it's hard to put it in perspective usage.
Post Reply