2 Test strrchr() function : usage variations - double quoted strings
5 /* Prototype : string strrchr(string $haystack, string $needle);
6 * Description: Finds the last occurrence of a character in a string.
7 * Source code: ext/standard/string.c
10 /* Test strrchr() function by passing various double quoted strings for 'haystack' & 'needle' */
12 echo "*** Testing strrchr() function: with various double quoted strings ***";
13 $haystack = "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ";
65 "12345", //decimal numeric string
66 "\x23", //hexadecimal numeric string
67 "#", //respective ASCII char of \x23
68 "\101", //octal numeric string
69 "A", //respective ASCII char of \101
70 "456HEE", //numerics + chars
71 42, //needle as int(ASCII value of "*")
72 $haystack //haystack as needle
75 /* loop through to get the position of the needle in haystack string */
77 for($index=0; $index<count($needle); $index++) {
78 echo "\n-- Iteration $count --\n";
79 var_dump( strrchr($haystack, $needle[$index]) );
85 *** Testing strrchr() function: with various double quoted strings ***
87 string(16) "lo123456he #4 A "
95 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
103 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
106 string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
111 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
115 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
118 string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
122 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
126 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
130 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
134 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
138 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
142 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
146 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
152 string(41) "$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
158 string(40) "&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
161 string(39) "!#%\o,()*+-./:;<=>?@hello123456he #4 A "
164 string(37) "%\o,()*+-./:;<=>?@hello123456he #4 A "
167 string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
170 string(33) "()*+-./:;<=>?@hello123456he #4 A "
173 string(31) "*+-./:;<=>?@hello123456he #4 A "
176 string(30) "+-./:;<=>?@hello123456he #4 A "
179 string(29) "-./:;<=>?@hello123456he #4 A "
182 string(28) "./:;<=>?@hello123456he #4 A "
185 string(28) "./:;<=>?@hello123456he #4 A "
188 string(26) ":;<=>?@hello123456he #4 A "
191 string(25) ";<=>?@hello123456he #4 A "
194 string(24) "<=>?@hello123456he #4 A "
197 string(22) ">?@hello123456he #4 A "
200 string(23) "=>?@hello123456he #4 A "
203 string(21) "?@hello123456he #4 A "
206 string(20) "@hello123456he #4 A "
209 string(20) "@hello123456he #4 A "
212 string(14) "123456he #4 A "
235 $&!#%\o,()*+-./:;<=>?@hello123456he #4 A "