PHP Wordwrap () function

Syntax :
string wordwrap ($str, $width, $break, $cut)
Parameters:The function takes 4 parameters as shown in the above syntax and described below:
  • $str : This parameter specifies the input string that is required for line breaks.
  • $width : This parameter specifies the number of characters to wrap the line. This is the number of characters after which the line will be broken.
  • $break : This is an optional parameter and, if specified, adds a value at the line break.
  • $cut : This is a boolean parameter, if this parameter is set to TRUE, the line is always wrapped to or before the specified width. That is, it will also break a word between them if it is in the middle of the constraint specified by the $width parameter. If this parameter is set to FALSE, the function does not split the word, even if the width is less than the width of the word.
  • Return value:The function returns a string enclosed in the specified length, those. a line, broken into lines on success, or FALSE on failure.The following programs illustrate the wordwrap() function in PHP:Program 1:  
    // Input line $str = "keep practicing at engineerforengineer" ;  
    // prints the wrapped line echo wordwrap ( $str , 15, "" , TRUE);  
    keep practicing at engineerforengineer
    Program 2:  
    // Input line $text = "Be a part of engineerforengineer." ;  
    // Line wrapped $newtext = wordwrap ( $text , 8, " " , TRUE); echo " $newtext " ;  
    Be a part of engineerfor engineer.
    http://php.net/ manual / en / function.wordwrap.php
    Get Solution for free from DataCamp guru