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