Core Function WordWrap

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
Line 20: Line 20:
  
 
Optional; The line is broken using this string.  
 
Optional; The line is broken using this string.  
 +
 +
Default: "\n"
  
 
==== cut ====
 
==== cut ====
  
 
If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).  
 
If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).  
 +
 +
Default: false
  
 
=== Return Value ===
 
=== Return Value ===

Revision as of 09:49, 4 September 2015

WordWrap( <str>, <width>, <break>, <cut> )

Contents

Description

Wraps a string to a given number of characters.

Parameters

str

The input string.

width

The number of characters at which the string will be wrapped.

break

Optional; The line is broken using this string.

Default: "\n"

cut

If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).

Default: false

Return Value

Success: Returns the given string wrapped at the specified length.

Failure: Returns empty string.

Remarks

None.

Example

$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");
 
echo $newtext;


$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", true);
 
echo "$newtext\n";
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox