2 Test strrchr() function : usage variations - single 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 single quoted strings to 'haystack' & 'needle' */
12 echo "*** Testing strrchr() function: with various single quoted strings ***";
13 $haystack = 'Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ';
65 '12345', //decimal numeric string
66 '\x23', //hexadecimal numeric string
67 '#', //hexadecimal numeric string
68 '\101', //octal numeric string
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 single quoted strings ***
87 string(22) "lo123456he \x234 \101 "
93 string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
96 string(14) "he \x234 \101 "
138 string(47) "$&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
144 string(46) "&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
147 string(45) "!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
150 string(43) "%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
156 string(39) "()*+-./:;<=>?@hello123456he \x234 \101 "
159 string(37) "*+-./:;<=>?@hello123456he \x234 \101 "
162 string(36) "+-./:;<=>?@hello123456he \x234 \101 "
165 string(35) "-./:;<=>?@hello123456he \x234 \101 "
168 string(34) "./:;<=>?@hello123456he \x234 \101 "
171 string(34) "./:;<=>?@hello123456he \x234 \101 "
174 string(32) ":;<=>?@hello123456he \x234 \101 "
177 string(31) ";<=>?@hello123456he \x234 \101 "
180 string(30) "<=>?@hello123456he \x234 \101 "
183 string(28) ">?@hello123456he \x234 \101 "
186 string(29) "=>?@hello123456he \x234 \101 "
189 string(27) "?@hello123456he \x234 \101 "
192 string(26) "@hello123456he \x234 \101 "
195 string(26) "@hello123456he \x234 \101 "
204 string(44) "#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "
219 string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "