| Wrap a long string/word |
|
|
|
As name states, wordwrap is handy function that wraps long words over multiple lines. There are occasions when a particular word is just too long and goes outside of provided space. (See wikipedia for longest words)
string wordwrap ( string source [, int width Example 1: Wrapping full words <?php $text = "Word wrap will split this text up into smaller lines, which makes for easier reading and neater layout."; $text = wordwrap($text, 20, ""); print $text; ?> Result: Word wrap will split If you wish to break long words, use the example below. The line will be wrapped after 6th character in the line: Example 2: Breaking long words <?php $text = "Micro-organism is a very long word."; $text = wordwrap($text, 6, "\n", 1); print $text; ?> Result: Micro- |



