Annotation of embedaddon/php/ext/standard/tests/strings/strtok_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strtok() function : usage variations - miscellaneous inputs
3: --FILE--
4: <?php
5: /* Prototype : string strtok ( str $str, str $token )
6: * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
7: * Source code: ext/standard/string.c
8: */
9:
10: /*
11: * Testing strtok() : with miscellaneous combinations of string and token
12: */
13:
14: echo "*** Testing strtok() : with miscellaneous inputs ***\n";
15:
16: // defining arrays for input strings and tokens
17: $string_array = array(
18: "HELLO WORLD",
19: "hello world",
20: "_HELLO_WORLD_",
21: "/thello/t/wor/ttld",
22: "hel/lo/t/world",
23: "one:$:two:!:three:#:four",
24: "\rhello/r/wor\rrld",
25: chr(0),
26: chr(0).chr(0),
27: chr(0).'hello'.chr(0),
28: 'hello'.chr(0).'world'
29: );
30: $token_array = array(
31: "wr",
32: "hello world",
33: "__",
34: "t/",
35: '/t',
36: ":",
37: "\r",
38: "\0",
39: "\0",
40: "\0",
41: "\0",
42: );
43:
44: // loop through each element of the array and check the working of strtok()
45: // when supplied with different string and token values
46:
47: $counter =1;
48: foreach( $string_array as $string ) {
49: echo "\n--- Iteration $counter ---\n";
50: var_dump( strtok($string, $token_array[$counter-1]) );
51: for( $count = 1; $count <=5; $count++ ) {
52: var_dump( strtok($token_array[$counter-1]) );
53: }
54: $counter++;
55: }
56:
57:
58: echo "Done\n";
59: ?>
60: --EXPECTF--
61: *** Testing strtok() : with miscellaneous inputs ***
62:
63: --- Iteration 1 ---
64: string(11) "HELLO WORLD"
65: bool(false)
66: bool(false)
67: bool(false)
68: bool(false)
69: bool(false)
70:
71: --- Iteration 2 ---
72: bool(false)
73: bool(false)
74: bool(false)
75: bool(false)
76: bool(false)
77: bool(false)
78:
79: --- Iteration 3 ---
80: string(5) "HELLO"
81: string(5) "WORLD"
82: bool(false)
83: bool(false)
84: bool(false)
85: bool(false)
86:
87: --- Iteration 4 ---
88: string(5) "hello"
89: string(3) "wor"
90: string(2) "ld"
91: bool(false)
92: bool(false)
93: bool(false)
94:
95: --- Iteration 5 ---
96: string(3) "hel"
97: string(2) "lo"
98: string(5) "world"
99: bool(false)
100: bool(false)
101: bool(false)
102:
103: --- Iteration 6 ---
104: string(3) "one"
105: string(1) "$"
106: string(3) "two"
107: string(1) "!"
108: string(5) "three"
109: string(1) "#"
110:
111: --- Iteration 7 ---
112: string(11) "hello/r/wor"
113: string(3) "rld"
114: bool(false)
115: bool(false)
116: bool(false)
117: bool(false)
118:
119: --- Iteration 8 ---
120: bool(false)
121: bool(false)
122: bool(false)
123: bool(false)
124: bool(false)
125: bool(false)
126:
127: --- Iteration 9 ---
128: bool(false)
129: bool(false)
130: bool(false)
131: bool(false)
132: bool(false)
133: bool(false)
134:
135: --- Iteration 10 ---
136: string(5) "hello"
137: bool(false)
138: bool(false)
139: bool(false)
140: bool(false)
141: bool(false)
142:
143: --- Iteration 11 ---
144: string(5) "hello"
145: string(5) "world"
146: bool(false)
147: bool(false)
148: bool(false)
149: bool(false)
150: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>