Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // To long
- $text = "Hi, this is a set with a too long woooooooooooooooooooooooooooooooooooooooooooooooooooord";
- // set maximum lenght
- $max = 30;
- // only to separate the long words
- $newtext = "";
- $words = explode ( " ", $text);
- foreach($words as $word)
- {
- if(strlen($word)>$max)
- {
- $newtext.=chunk_split ( $word, $max, "-<br />");
- }
- else
- {
- $newtext.=$word." ";
- }
- }
- // the output
- echo $newtext;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment