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