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