Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 379
0 Users 4 Guests Online

Word Wrap

Normally when you have a site people tend to be rude and sign up with really long usernames or post one really long line of text on forums. Sure, there are other ways of fixing this like limiting the text box with:
Code

<input type="text" name="user" size="15" maxlength="20">

size is how wide it is and maxlength is how many characters the box will hold.

So, now on with the tutorial.

Code

<?php
$string = "This is an example of a really really really long post that may stretch your page a few inches or pixels and make the layout look like crap"; //Demo string though you can replace it with something else

$wrap = wordwrap($string, 15, "<br />\n"); //this tells the script to wrap the text to 15 characters per line.

echo "$wrap"; //Echo the wrapped Text
?>


That string there would come back as:
Code

This is an
example of a
really really
really long
post that may
stretch your
page a few
inches or
pixels and make
the layout look
like crap

That may look bad but in some situations it can make things better.
[ ] = Optional
Code

wordwrap ( string [, length [, break [, bool cut}}] );


If you don't put in a length the default is 75 i believe.
ShadowMage
Author:
Views:
1949
Rating:
There are currently no comments for this tutorial.