1--TEST--
2Test 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
14echo "*** 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;
29for($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}
36echo "*** Done ***";
37?>
38--EXPECTF--
39*** Testing stripos() function: strings repetitive chars ***
40
41-- Iteration 1 --
42int(0)
43int(2)
44int(2)
45int(4)
46int(4)
47int(6)
48int(6)
49int(8)
50int(8)
51int(10)
52int(10)
53int(12)
54int(12)
55int(14)
56int(14)
57int(16)
58int(16)
59bool(false)
60bool(false)
61bool(false)
62
63-- Iteration 2 --
64int(0)
65int(2)
66int(2)
67int(4)
68int(4)
69int(6)
70int(6)
71int(8)
72int(8)
73int(10)
74int(10)
75int(12)
76int(12)
77int(14)
78int(14)
79int(16)
80int(16)
81bool(false)
82bool(false)
83bool(false)
84
85-- Iteration 3 --
86int(0)
87int(2)
88int(2)
89int(4)
90int(4)
91int(6)
92int(6)
93int(8)
94int(8)
95int(10)
96int(10)
97int(12)
98int(12)
99int(14)
100int(14)
101int(16)
102int(16)
103bool(false)
104bool(false)
105bool(false)
106
107-- Iteration 4 --
108int(0)
109int(2)
110int(2)
111int(4)
112int(4)
113int(6)
114int(6)
115int(8)
116int(8)
117int(10)
118int(10)
119int(12)
120int(12)
121int(14)
122int(14)
123int(16)
124int(16)
125bool(false)
126bool(false)
127bool(false)
128
129-- Iteration 5 --
130int(1)
131int(1)
132int(3)
133int(3)
134int(5)
135int(5)
136int(7)
137int(7)
138int(9)
139int(9)
140int(11)
141int(11)
142int(13)
143int(13)
144int(15)
145int(15)
146bool(false)
147bool(false)
148bool(false)
149bool(false)
150
151-- Iteration 6 --
152int(1)
153int(1)
154int(3)
155int(3)
156int(5)
157int(5)
158int(7)
159int(7)
160int(9)
161int(9)
162int(11)
163int(11)
164int(13)
165int(13)
166int(15)
167int(15)
168bool(false)
169bool(false)
170bool(false)
171bool(false)
172
173-- Iteration 7 --
174int(1)
175int(1)
176int(3)
177int(3)
178int(5)
179int(5)
180int(7)
181int(7)
182int(9)
183int(9)
184int(11)
185int(11)
186int(13)
187int(13)
188int(15)
189int(15)
190bool(false)
191bool(false)
192bool(false)
193bool(false)
194
195-- Iteration 8 --
196int(1)
197int(1)
198int(3)
199int(3)
200int(5)
201int(5)
202int(7)
203int(7)
204int(9)
205int(9)
206int(11)
207int(11)
208int(13)
209int(13)
210int(15)
211int(15)
212bool(false)
213bool(false)
214bool(false)
215bool(false)
216*** Done ***
217