1--TEST--
2Test chunk_split() function : usage variations - different double quoted strings for 'ending' argument
3--FILE--
4<?php
5/* Prototype  : string chunk_split(string $str [, int $chunklen [, string $ending]])
6 * Description: Returns split line
7 * Source code: ext/standard/string.c
8 * Alias to functions: none
9*/
10
11/*
12* passing different double quoted strings for 'ending' argument to chunk_split()
13* here 'chunklen' is set to 6.5
14*/
15
16echo "*** Testing chunk_split() : different strings for 'ending' ***\n";
17
18//Initializing variables
19$str = "This is to test chunk_split() with various ending string";
20$chunklen = 6.5;
21
22//different values for 'ending' argument
23$values = array (
24  "",  //empty
25  " ",  //space
26  "a",  //Single char
27  "ENDING",  //regular string
28  "@#$%^",  //Special chars
29
30  // white space chars
31  "\t",
32  "\n",
33  "\r",
34  "\r\n",
35
36  "\0",  //Null char
37  "123",  //Numeric
38  "(MSG)",  //With ( and )
39  ")ending string(",  //sentence as ending string
40  ")numbers 1234(",
41  ")speci@! ch@r$("
42);
43
44//loop through element of values for 'ending'
45for($count = 0; $count < count($values); $count++) {
46  echo "-- Iteration $count --\n";
47  var_dump( chunk_split($str, $chunklen, $values[$count]) );
48}
49
50echo "Done"
51?>
52--EXPECT--
53*** Testing chunk_split() : different strings for 'ending' ***
54-- Iteration 0 --
55string(56) "This is to test chunk_split() with various ending string"
56-- Iteration 1 --
57string(66) "This i s to t est ch unk_sp lit()  with v arious  endin g stri ng "
58-- Iteration 2 --
59string(66) "This ias to taest chaunk_spalit() awith vaariousa endinag strianga"
60-- Iteration 3 --
61string(116) "This iENDINGs to tENDINGest chENDINGunk_spENDINGlit() ENDINGwith vENDINGariousENDING endinENDINGg striENDINGngENDING"
62-- Iteration 4 --
63string(106) "This i@#$%^s to t@#$%^est ch@#$%^unk_sp@#$%^lit() @#$%^with v@#$%^arious@#$%^ endin@#$%^g stri@#$%^ng@#$%^"
64-- Iteration 5 --
65string(66) "This i	s to t	est ch	unk_sp	lit() 	with v	arious	 endin	g stri	ng	"
66-- Iteration 6 --
67string(66) "This i
68s to t
69est ch
70unk_sp
71lit()
72with v
73arious
74 endin
75g stri
76ng
77"
78-- Iteration 7 --
79string(66) "This i
79s to t
79est ch
79unk_sp
79lit()
79with v
79arious
79 endin
79g stri
79ng
79"
80-- Iteration 8 --
81string(76) "This i
82s to t
83est ch
84unk_sp
85lit()
86with v
87arious
88 endin
89g stri
90ng
91"
92-- Iteration 9 --
93string(66) "This i�s to t�est ch�unk_sp�lit() �with v�arious� endin�g stri�ng�"
94-- Iteration 10 --
95string(86) "This i123s to t123est ch123unk_sp123lit() 123with v123arious123 endin123g stri123ng123"
96-- Iteration 11 --
97string(106) "This i(MSG)s to t(MSG)est ch(MSG)unk_sp(MSG)lit() (MSG)with v(MSG)arious(MSG) endin(MSG)g stri(MSG)ng(MSG)"
98-- Iteration 12 --
99string(206) "This i)ending string(s to t)ending string(est ch)ending string(unk_sp)ending string(lit() )ending string(with v)ending string(arious)ending string( endin)ending string(g stri)ending string(ng)ending string("
100-- Iteration 13 --
101string(196) "This i)numbers 1234(s to t)numbers 1234(est ch)numbers 1234(unk_sp)numbers 1234(lit() )numbers 1234(with v)numbers 1234(arious)numbers 1234( endin)numbers 1234(g stri)numbers 1234(ng)numbers 1234("
102-- Iteration 14 --
103string(206) "This i)speci@! ch@r$(s to t)speci@! ch@r$(est ch)speci@! ch@r$(unk_sp)speci@! ch@r$(lit() )speci@! ch@r$(with v)speci@! ch@r$(arious)speci@! ch@r$( endin)speci@! ch@r$(g stri)speci@! ch@r$(ng)speci@! ch@r$("
104Done
105