PHP

PHP Menu

PHP

wordwrap() Function - Definition, Syntax, Parameters, Examples

Definition

The wordwrap() function wraps a string into new lines when it reaches a specific length.

Syntax

wordwrap(string, width, break, cut)

Parameters

Parameter Description
string Required. Specifies the string to break up into lines.
width Optional. Specifies the maximum line width. Default is 75.
break Optional. Specifies the characters to use as break. Default is "\n".
cut Optional. Specifies whether words longer than the specified width should be wrapped:
false - Default. No-wrap
true - Wrap.

Example

<?php
$str = "An example of a long word is: Supercalifragulistic"; echo wordwrap($str, 15, "<br>\n");

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods