Example 1 — Wrap Text at 15 Characters
Break a long sentence into shorter lines.
<?php
$text = "The quick brown fox sat over the lazy dog";
echo wordwrap($text, 15, PHP_EOL), PHP_EOL; How It Works
- Set the width. Each line can hold up to 15 characters.
- Break at spaces. PHP never splits a normal word.
- Use PHP_EOL. It is the break inserted between lines.
- Print. Three tidy lines appear.

