1--TEST--
2Test strrchr() function : usage variations - double quoted strings
3--FILE--
4<?php
5
6/* Test strrchr() function by passing various double quoted strings for 'haystack' & 'needle' */
7
8echo "*** Testing strrchr() function: with various double quoted strings ***";
9$haystack = "Hello,\t\n\0\n  $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ";
10$needle = array(
11  //regular strings
12  "l",
13  "L",
14  "HELLO",
15  "hEllo",
16
17  //escape characters
18  "\t",
19  "\T",
20  "	",
21  "\n",
22  "\N",
23  "
24",  //new line
25
26  //nulls
27  "\0",
28
29  //boolean false
30  FALSE,
31  false,
32
33  //empty string
34  "",
35
36  //special chars
37  " ",
38  "$",
39  " $",
40  "&",
41  "!#",
42  "%\o",
43  "\o,",
44  "()",
45  "*+",
46  "+",
47  "-",
48  ".",
49  ".;",
50  ":;",
51  ";",
52  "<=>",
53  ">",
54  "=>",
55  "?",
56  "@",
57  "@hEllo",
58
59  "12345", //decimal numeric string
60  "\x23",  //hexadecimal numeric string
61  "#",  //respective ASCII char of \x23
62  "\101",  //octal numeric string
63  "A",  //respective ASCII char of \101
64  "456HEE",  //numerics + chars
65  42, //needle as int(ASCII value of "*")
66  $haystack  //haystack as needle
67);
68
69/* loop through to get the position of the needle in haystack string */
70$count = 1;
71for($index=0; $index<count($needle); $index++) {
72  echo "\n-- Iteration $count --\n";
73  var_dump( strrchr($haystack, $needle[$index]) );
74  $count++;
75}
76echo "*** Done ***";
77?>
78--EXPECTF--
79*** Testing strrchr() function: with various double quoted strings ***
80-- Iteration 1 --
81string(16) "lo123456he #4 A "
82
83-- Iteration 2 --
84bool(false)
85
86-- Iteration 3 --
87string(53) "Hello,
88%0
89  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
90
91-- Iteration 4 --
92string(8) "he #4 A "
93
94-- Iteration 5 --
95string(47) "
96%0
97  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
98
99-- Iteration 6 --
100string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
101
102-- Iteration 7 --
103string(47) "
104%0
105  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
106
107-- Iteration 8 --
108string(44) "
109  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
110
111-- Iteration 9 --
112string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
113
114-- Iteration 10 --
115string(44) "
116  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
117
118-- Iteration 11 --
119string(45) "%0
120  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
121
122-- Iteration 12 --
123string(45) "%0
124  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
125
126-- Iteration 13 --
127string(45) "%0
128  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
129
130-- Iteration 14 --
131string(45) "%0
132  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
133
134-- Iteration 15 --
135string(1) " "
136
137-- Iteration 16 --
138string(41) "$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
139
140-- Iteration 17 --
141string(1) " "
142
143-- Iteration 18 --
144string(40) "&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
145
146-- Iteration 19 --
147string(39) "!#%\o,()*+-./:;<=>?@hello123456he #4 A "
148
149-- Iteration 20 --
150string(37) "%\o,()*+-./:;<=>?@hello123456he #4 A "
151
152-- Iteration 21 --
153string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
154
155-- Iteration 22 --
156string(33) "()*+-./:;<=>?@hello123456he #4 A "
157
158-- Iteration 23 --
159string(31) "*+-./:;<=>?@hello123456he #4 A "
160
161-- Iteration 24 --
162string(30) "+-./:;<=>?@hello123456he #4 A "
163
164-- Iteration 25 --
165string(29) "-./:;<=>?@hello123456he #4 A "
166
167-- Iteration 26 --
168string(28) "./:;<=>?@hello123456he #4 A "
169
170-- Iteration 27 --
171string(28) "./:;<=>?@hello123456he #4 A "
172
173-- Iteration 28 --
174string(26) ":;<=>?@hello123456he #4 A "
175
176-- Iteration 29 --
177string(25) ";<=>?@hello123456he #4 A "
178
179-- Iteration 30 --
180string(24) "<=>?@hello123456he #4 A "
181
182-- Iteration 31 --
183string(22) ">?@hello123456he #4 A "
184
185-- Iteration 32 --
186string(23) "=>?@hello123456he #4 A "
187
188-- Iteration 33 --
189string(21) "?@hello123456he #4 A "
190
191-- Iteration 34 --
192string(20) "@hello123456he #4 A "
193
194-- Iteration 35 --
195string(20) "@hello123456he #4 A "
196
197-- Iteration 36 --
198string(14) "123456he #4 A "
199
200-- Iteration 37 --
201string(5) "#4 A "
202
203-- Iteration 38 --
204string(5) "#4 A "
205
206-- Iteration 39 --
207string(2) "A "
208
209-- Iteration 40 --
210string(2) "A "
211
212-- Iteration 41 --
213string(4) "4 A "
214
215-- Iteration 42 --
216string(4) "4 A "
217
218-- Iteration 43 --
219string(53) "Hello,
220%0
221  $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
222*** Done ***
223