1--TEST--
2Test ucwords() function : usage variations - double quoted string
3--FILE--
4<?php
5/* Prototype  : string ucwords ( string $str )
6 * Description: Uppercase the first character of each word in a string
7 * Source code: ext/standard/string.c
8*/
9
10/*
11 * test ucwords() with different string prepared using double quote
12*/
13
14echo "*** Testing ucwords() : usage variations ***\n";
15
16// different strings containing regular chars and special chars
17$str_array = array(
18  // multiple spaces
19  "testing    ucwords",
20  "t e s t i n g   u c w o r d s ",
21
22  // brackets in sentence
23  "testing function(ucwords)",
24  "(testing ( function (ucwords) )a )test",
25  "(t)",
26  " ( t )t",
27
28  // using quote chars in sentence
29  "\"testing\",ucwords,\"test\"",
30  "\"t\"\"t\",test, t",
31  "\'t \'t\',test",
32  "Jack's pen",
33  "P't'y 't it's ",
34
35  // using other white spaces
36  "\ttesting\ttesting\tucwords",
37  "\\ttesting\\ttesting\tucwords",
38  "testing\rucwords testing ucwords",
39  "testing\\rucwords testing ucwords",
40  "testing\fucwords \f testing \nucwords",
41  "testing\\fucwords \\f testing \nucwords",
42  "\ntesting\nucwords\n testing \n ucwords",
43  "\\ntesting\\nucwords\\n testing \\n ucwords",
44  "using\vvertical\vtab",
45  "using\\vvertical\\vtab",
46
47  //using special chars in sentence
48  "t@@#$% %test ^test &test *test +test -test",
49  "!test ~test `test` =test= @test@test.com",
50  "/test/r\test\\ucwords\t\y\y\\u\3 \yy\ /uu/",
51
52  //only special chars
53  "!@#$%^&*()_+=-`~"
54);
55
56// loop through the $str_array array to test ucwords on each element
57$iteration = 1;
58for($index = 0; $index < count($str_array); $index++) {
59  echo "-- Iteration $iteration --\n";
60  var_dump( ucwords($str_array[$index]) );
61  $iteration++;
62}
63
64echo "Done\n";
65?>
66--EXPECTF--
67*** Testing ucwords() : usage variations ***
68-- Iteration 1 --
69string(18) "Testing    Ucwords"
70-- Iteration 2 --
71string(30) "T E S T I N G   U C W O R D S "
72-- Iteration 3 --
73string(25) "Testing Function(ucwords)"
74-- Iteration 4 --
75string(38) "(testing ( Function (ucwords) )a )test"
76-- Iteration 5 --
77string(3) "(t)"
78-- Iteration 6 --
79string(7) " ( T )t"
80-- Iteration 7 --
81string(24) ""testing",ucwords,"test""
82-- Iteration 8 --
83string(14) ""t""t",test, T"
84-- Iteration 9 --
85string(14) "\'t \'t\',test"
86-- Iteration 10 --
87string(10) "Jack's Pen"
88-- Iteration 11 --
89string(14) "P't'y 't It's "
90-- Iteration 12 --
91string(24) "	Testing	Testing	Ucwords"
92-- Iteration 13 --
93string(26) "\ttesting\ttesting	Ucwords"
94-- Iteration 14 --
95string(31) "Testing
95Ucwords Testing Ucwords"
96-- Iteration 15 --
97string(32) "Testing\rucwords Testing Ucwords"
98-- Iteration 16 --
99string(34) "TestingUcwords  Testing
100Ucwords"
101-- Iteration 17 --
102string(36) "Testing\fucwords \f Testing
103Ucwords"
104-- Iteration 18 --
105string(35) "
106Testing
107Ucwords
108 Testing
109 Ucwords"
110-- Iteration 19 --
111string(39) "\ntesting\nucwords\n Testing \n Ucwords"
112-- Iteration 20 --
113string(18) "UsingVerticalTab"
114-- Iteration 21 --
115string(20) "Using\vvertical\vtab"
116-- Iteration 22 --
117string(42) "T@@#$% %test ^test &test *test +test -test"
118-- Iteration 23 --
119string(40) "!test ~test `test` =test= @test@test.com"
120-- Iteration 24 --
121string(37) "/test/r	Est\ucwords	\y\y\u \yy\ /uu/"
122-- Iteration 25 --
123string(16) "!@#$%^&*()_+=-`~"
124Done
125