Wraps A String To A Given Number Of Characters Using A String Break Character

 
 
Returns a string with str wrapped at the column number specified by the optional width parameter. The line is broken using the (optional) break parameter. wordwrap() will automatically wrap at column 75 and break using 'n' (newline) if width or break are not given. If the cut is set to 1, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).
 
 
  1. <?php

  2. $text = "The quick brown fox jumped over the lazy dog.";

  3. $newtext = wordwrap($text, 20, "<br />n");

  4.  

  5. echo $newtext;

  6. ?>
 
Copy to Clipboard      Download code as Text Format
 
  Date entered : 3rd Apr 2008
  Rating : No Rating
  Accessed  :  6062
  Submitted by :  goldeekhan
 
   Add Comment  Printer friendly
   View All Comments  Email to a friend
   Add to my Favourites Download PDF version
   Rating  
 
                 Click each image to add
this page to each site.
 
 
 
Comments Available

    No comment available at the moment.Be the first one to make a comment

 
Related PHP Source Codes
  • Spring
  • Uppercase the first character of each word in a string
  • Make a string's first character uppercase
  • Strip whitespace (or other characters) from the beginning and end of a string
  • Return part of a string

  • Copyright © 2013 VisualBuilder. All rights reserved

    Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

    Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0