1--TEST-- 2Test wordwrap() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] ) 6 * Description: Wraps buffer to selected number of characters using string break char 7 * Source code: ext/standard/string.c 8*/ 9 10echo "*** Testing wordwrap() : basic functionality ***\n"; 11 12// Initialize all required variables 13$str = "The quick brown foooooooooox jummmmmmmmmmmmped over the lazzzzzzzzzzzy doooooooooooooooooooooog."; 14$width = 80; 15$break = '<br />\n'; 16 17// Calling wordwrap() with default arguments 18var_dump( wordwrap($str) ); 19 20// Calling wordwrap() with all possible optional arguments 21// with $width arg 22var_dump( wordwrap($str, $width) ); 23// with $break arg 24var_dump( wordwrap($str, $width, $break) ); 25 26// Calling wordwrap() with all arguments 27// $cut as true 28$width = 10; 29$cut = true; 30var_dump( wordwrap($str, $width, $break, $cut) ); 31 32// $cut as false 33$width = 10; 34$cut = false; 35var_dump( wordwrap($str, $width, $break, $cut) ); 36echo "Done\n"; 37?> 38--EXPECTF-- 39*** Testing wordwrap() : basic functionality *** 40string(96) "The quick brown foooooooooox jummmmmmmmmmmmped over the lazzzzzzzzzzzy 41doooooooooooooooooooooog." 42string(96) "The quick brown foooooooooox jummmmmmmmmmmmped over the lazzzzzzzzzzzy 43doooooooooooooooooooooog." 44string(103) "The quick brown foooooooooox jummmmmmmmmmmmped over the lazzzzzzzzzzzy<br />\ndoooooooooooooooooooooog." 45string(178) "The quick<br />\nbrown<br />\nfooooooooo<br />\nox<br />\njummmmmmmm<br />\nmmmmped<br />\nover the<br />\nlazzzzzzzz<br />\nzzzy<br />\ndooooooooo<br />\noooooooooo<br />\nooog." 46string(138) "The quick<br />\nbrown<br />\nfoooooooooox<br />\njummmmmmmmmmmmped<br />\nover the<br />\nlazzzzzzzzzzzy<br />\ndoooooooooooooooooooooog." 47Done 48