1--TEST-- 2Bug #61780 (Inconsistent PCRE captures in match results): numeric subpatterns 3--FILE-- 4<?php 5preg_match('/(4)?(2)?\d/', '23456', $matches, PREG_UNMATCHED_AS_NULL); 6var_export($matches); 7echo "\n\n"; 8preg_match('/(4)?(2)?\d/', '23456', $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL); 9var_export($matches); 10echo "\n\n"; 11preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_UNMATCHED_AS_NULL); 12var_export($matches); 13echo "\n\n"; 14preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL); 15var_export($matches); 16echo "\n\n"; 17preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL); 18var_export($matches); 19echo "\n\n"; 20preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL); 21var_export($matches); 22?> 23--EXPECT-- 24array ( 25 0 => '23', 26 1 => NULL, 27 2 => '2', 28) 29 30array ( 31 0 => 32 array ( 33 0 => '23', 34 1 => 0, 35 ), 36 1 => 37 array ( 38 0 => NULL, 39 1 => -1, 40 ), 41 2 => 42 array ( 43 0 => '2', 44 1 => 0, 45 ), 46) 47 48array ( 49 0 => 50 array ( 51 0 => '1', 52 1 => '23', 53 2 => '45', 54 3 => '6', 55 ), 56 1 => 57 array ( 58 0 => NULL, 59 1 => NULL, 60 2 => '4', 61 3 => NULL, 62 ), 63 2 => 64 array ( 65 0 => NULL, 66 1 => '2', 67 2 => NULL, 68 3 => NULL, 69 ), 70) 71 72array ( 73 0 => 74 array ( 75 0 => 76 array ( 77 0 => '1', 78 1 => 0, 79 ), 80 1 => 81 array ( 82 0 => '23', 83 1 => 1, 84 ), 85 2 => 86 array ( 87 0 => '45', 88 1 => 3, 89 ), 90 3 => 91 array ( 92 0 => '6', 93 1 => 5, 94 ), 95 ), 96 1 => 97 array ( 98 0 => 99 array ( 100 0 => NULL, 101 1 => -1, 102 ), 103 1 => 104 array ( 105 0 => NULL, 106 1 => -1, 107 ), 108 2 => 109 array ( 110 0 => '4', 111 1 => 3, 112 ), 113 3 => 114 array ( 115 0 => NULL, 116 1 => -1, 117 ), 118 ), 119 2 => 120 array ( 121 0 => 122 array ( 123 0 => NULL, 124 1 => -1, 125 ), 126 1 => 127 array ( 128 0 => '2', 129 1 => 1, 130 ), 131 2 => 132 array ( 133 0 => NULL, 134 1 => -1, 135 ), 136 3 => 137 array ( 138 0 => NULL, 139 1 => -1, 140 ), 141 ), 142) 143 144array ( 145 0 => 146 array ( 147 0 => '1', 148 1 => NULL, 149 2 => NULL, 150 ), 151 1 => 152 array ( 153 0 => '23', 154 1 => NULL, 155 2 => '2', 156 ), 157 2 => 158 array ( 159 0 => '45', 160 1 => '4', 161 2 => NULL, 162 ), 163 3 => 164 array ( 165 0 => '6', 166 1 => NULL, 167 2 => NULL, 168 ), 169) 170 171array ( 172 0 => 173 array ( 174 0 => 175 array ( 176 0 => '1', 177 1 => 0, 178 ), 179 1 => 180 array ( 181 0 => NULL, 182 1 => -1, 183 ), 184 2 => 185 array ( 186 0 => NULL, 187 1 => -1, 188 ), 189 ), 190 1 => 191 array ( 192 0 => 193 array ( 194 0 => '23', 195 1 => 1, 196 ), 197 1 => 198 array ( 199 0 => NULL, 200 1 => -1, 201 ), 202 2 => 203 array ( 204 0 => '2', 205 1 => 1, 206 ), 207 ), 208 2 => 209 array ( 210 0 => 211 array ( 212 0 => '45', 213 1 => 3, 214 ), 215 1 => 216 array ( 217 0 => '4', 218 1 => 3, 219 ), 220 2 => 221 array ( 222 0 => NULL, 223 1 => -1, 224 ), 225 ), 226 3 => 227 array ( 228 0 => 229 array ( 230 0 => '6', 231 1 => 5, 232 ), 233 1 => 234 array ( 235 0 => NULL, 236 1 => -1, 237 ), 238 2 => 239 array ( 240 0 => NULL, 241 1 => -1, 242 ), 243 ), 244) 245