Annotation of embedaddon/php/ext/standard/tests/strings/stripos_variation8.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test stripos() function : usage variations - repetitive chars for 'haystack' argument
3: --FILE--
4: <?php
5: /* Prototype : int stripos ( string $haystack, string $needle [, int $offset] );
6: * Description: Find position of first occurrence of a case-insensitive string
7: * Source code: ext/standard/string.c
8: */
9:
10: /* Test stripos() function with strings containing repetitive chars for haystak
11: * and with various needles & offsets
12: */
13:
14: echo "*** Testing stripos() function: strings repetitive chars ***\n";
15: $haystack = "aBAbaBAbaBabAbAbaBa";
16: $needles = array(
17: "aba",
18: "aBA",
19: "ABA",
20: "Aba",
21: "BAb",
22: "bab",
23: "bAb",
24: "BAB"
25: );
26:
27: /* loop through to consider various offsets in getting the position of the needle in haystack string */
28: $count = 1;
29: for($index = 0; $index < count($needles); $index++) {
30: echo "\n-- Iteration $count --\n";
31: for($offset = 0; $offset <= strlen($haystack); $offset++ ) {
32: var_dump( stripos($haystack, $needles[$index], $offset) );
33: }
34: $count++;
35: }
36: echo "*** Done ***";
37: ?>
38: --EXPECTF--
39: *** Testing stripos() function: strings repetitive chars ***
40:
41: -- Iteration 1 --
42: int(0)
43: int(2)
44: int(2)
45: int(4)
46: int(4)
47: int(6)
48: int(6)
49: int(8)
50: int(8)
51: int(10)
52: int(10)
53: int(12)
54: int(12)
55: int(14)
56: int(14)
57: int(16)
58: int(16)
59: bool(false)
60: bool(false)
61: bool(false)
62:
63: -- Iteration 2 --
64: int(0)
65: int(2)
66: int(2)
67: int(4)
68: int(4)
69: int(6)
70: int(6)
71: int(8)
72: int(8)
73: int(10)
74: int(10)
75: int(12)
76: int(12)
77: int(14)
78: int(14)
79: int(16)
80: int(16)
81: bool(false)
82: bool(false)
83: bool(false)
84:
85: -- Iteration 3 --
86: int(0)
87: int(2)
88: int(2)
89: int(4)
90: int(4)
91: int(6)
92: int(6)
93: int(8)
94: int(8)
95: int(10)
96: int(10)
97: int(12)
98: int(12)
99: int(14)
100: int(14)
101: int(16)
102: int(16)
103: bool(false)
104: bool(false)
105: bool(false)
106:
107: -- Iteration 4 --
108: int(0)
109: int(2)
110: int(2)
111: int(4)
112: int(4)
113: int(6)
114: int(6)
115: int(8)
116: int(8)
117: int(10)
118: int(10)
119: int(12)
120: int(12)
121: int(14)
122: int(14)
123: int(16)
124: int(16)
125: bool(false)
126: bool(false)
127: bool(false)
128:
129: -- Iteration 5 --
130: int(1)
131: int(1)
132: int(3)
133: int(3)
134: int(5)
135: int(5)
136: int(7)
137: int(7)
138: int(9)
139: int(9)
140: int(11)
141: int(11)
142: int(13)
143: int(13)
144: int(15)
145: int(15)
146: bool(false)
147: bool(false)
148: bool(false)
149: bool(false)
150:
151: -- Iteration 6 --
152: int(1)
153: int(1)
154: int(3)
155: int(3)
156: int(5)
157: int(5)
158: int(7)
159: int(7)
160: int(9)
161: int(9)
162: int(11)
163: int(11)
164: int(13)
165: int(13)
166: int(15)
167: int(15)
168: bool(false)
169: bool(false)
170: bool(false)
171: bool(false)
172:
173: -- Iteration 7 --
174: int(1)
175: int(1)
176: int(3)
177: int(3)
178: int(5)
179: int(5)
180: int(7)
181: int(7)
182: int(9)
183: int(9)
184: int(11)
185: int(11)
186: int(13)
187: int(13)
188: int(15)
189: int(15)
190: bool(false)
191: bool(false)
192: bool(false)
193: bool(false)
194:
195: -- Iteration 8 --
196: int(1)
197: int(1)
198: int(3)
199: int(3)
200: int(5)
201: int(5)
202: int(7)
203: int(7)
204: int(9)
205: int(9)
206: int(11)
207: int(11)
208: int(13)
209: int(13)
210: int(15)
211: int(15)
212: bool(false)
213: bool(false)
214: bool(false)
215: bool(false)
216: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>