1--TEST--
2Test ucwords() function : basic functionality
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
10echo "*** Testing ucwords() : basic functionality ***\n";
11
12// lines with different whitespace charecter
13$str_array = array(
14 "testing ucwords",
15 'testing ucwords',
16 'testing\tucwords',
17 "testing\tucwords",
18 "testing\nucwords",
19 'testing\nucwords',
20 "testing\vucwords",
21 'testing\vucwords',
22 "testing",
23 'testing',
24 ' testing',
25 " testing",
26 "testing  ucwords",
27 'testing  ucwords',
28 'testing\rucwords',
29 "testing\rucwords",
30 'testing\fucwords',
31 "testing\fucwords"
32);
33
34// loop through the $strings array to test ucwords on each element
35$iteration = 1;
36for($index = 0; $index < count($str_array); $index++) {
37  echo "-- Iteration $iteration --\n";
38  var_dump( ucwords($str_array[$index]) );
39  $iteration++;
40}
41
42echo "Done\n";
43?>
44--EXPECT--
45*** Testing ucwords() : basic functionality ***
46-- Iteration 1 --
47string(15) "Testing Ucwords"
48-- Iteration 2 --
49string(15) "Testing Ucwords"
50-- Iteration 3 --
51string(16) "Testing\tucwords"
52-- Iteration 4 --
53string(15) "Testing	Ucwords"
54-- Iteration 5 --
55string(15) "Testing
56Ucwords"
57-- Iteration 6 --
58string(16) "Testing\nucwords"
59-- Iteration 7 --
60string(15) "TestingUcwords"
61-- Iteration 8 --
62string(16) "Testing\vucwords"
63-- Iteration 9 --
64string(7) "Testing"
65-- Iteration 10 --
66string(7) "Testing"
67-- Iteration 11 --
68string(8) " Testing"
69-- Iteration 12 --
70string(8) " Testing"
71-- Iteration 13 --
72string(16) "Testing  Ucwords"
73-- Iteration 14 --
74string(16) "Testing  Ucwords"
75-- Iteration 15 --
76string(16) "Testing\rucwords"
77-- Iteration 16 --
78string(15) "Testing
78Ucwords"
79-- Iteration 17 --
80string(16) "Testing\fucwords"
81-- Iteration 18 --
82string(15) "TestingUcwords"
83Done
84