1--TEST--
2Test wordwrap() function : usage variations  - valid break arguments(spaces)
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
10/*
11 *test wordwrap() with break arguments as single spaces
12*/
13
14echo "*** Testing wordwrap() : usage variations ***\n";
15
16// Initialize all required variables
17$str = "Testing wordrap function";
18$width = 1;
19$cut = false;
20
21echo "\n-- Testing wordwrap() with default break value and single space as value --\n";
22echo "-- with default break and cut value --\n";
23var_dump( wordwrap($str, $width) );  // default break and cut value
24
25echo "-- with default cut value --\n";
26$break = ' ';
27$break1 = "  ";
28var_dump( wordwrap($str, $width, $break) );
29var_dump( wordwrap($str, $width, $break1) );
30
31echo "-- with cut value as false --\n";
32$cut = false;
33var_dump( wordwrap($str, $width, $break, $cut) );
34var_dump( wordwrap($str, $width, $break1, $cut) );
35
36echo "-- with cut value as true --\n";
37$cut = true;
38var_dump( wordwrap($str, $width, $break, $cut) );
39var_dump( wordwrap($str, $width, $break1, $cut) );
40
41echo "Done\n";
42?>
43--EXPECTF--
44*** Testing wordwrap() : usage variations ***
45
46-- Testing wordwrap() with default break value and single space as value --
47-- with default break and cut value --
48string(24) "Testing
49wordrap
50function"
51-- with default cut value --
52string(24) "Testing wordrap function"
53string(26) "Testing  wordrap  function"
54-- with cut value as false --
55string(24) "Testing wordrap function"
56string(26) "Testing  wordrap  function"
57-- with cut value as true --
58string(43) "T e s t i n g w o r d r a p f u n c t i o n"
59string(64) "T  e  s  t  i  n  g  w  o  r  d  r  a  p  f  u  n  c  t  i  o  n"
60Done
61