@@ -145,7 +145,9 @@ public static function parseParsedAddress(
145145 if ($ regionInput === '' ) {
146146 return $ result ;
147147 }
148- $ regionMatches = array_filter ($ level3Data , fn ($ v ) => mb_strpos ($ v ['name ' ], $ regionInput ) !== false );
148+ $ regionMatches = array_filter ($ level3Data , function ($ v ) use ($ regionInput ) {
149+ return mb_strpos ($ v ['name ' ], $ regionInput ) !== false ;
150+ });
149151 if (count ($ regionMatches ) > 1 ) {
150152 $ result = self ::handleMultipleRegionMatches ($ regionMatches , $ cityInput , $ unknownValue , $ level1Data , $ level2Data , $ regionInput );
151153 } elseif (count ($ regionMatches ) === 1 ) {
@@ -179,7 +181,9 @@ private static function handleMultipleRegionMatches(array $regionMatches, string
179181 'city ' => $ unknownValue ,
180182 'region ' => $ unknownValue
181183 ];
182- $ cityMatches = array_filter ($ level2Data , fn ($ v ) => mb_strpos ($ v ['name ' ], $ cityInput ) !== false );
184+ $ cityMatches = array_filter ($ level2Data , function ($ v ) use ($ cityInput ) {
185+ return mb_strpos ($ v ['name ' ], $ cityInput ) !== false ;
186+ });
183187 if (count ($ cityMatches ) > 1 ) {
184188 foreach ($ regionMatches as $ regionMatch ) {
185189 foreach ($ cityMatches as $ id => $ city ) {
@@ -206,7 +210,10 @@ private static function handleMultipleRegionMatches(array $regionMatches, string
206210 }
207211 }
208212 if (count ($ cityMatches ) === 0 ) {
209- $ provinceMatches = array_filter ($ level1Data , fn ($ v ) => mb_strpos ($ v ['name ' ], $ cityInput ) !== false );
213+ $ provinceMatches = array_filter ($ level1Data , function ($ v ) use ($ cityInput ) {
214+ return mb_strpos ($ v ['name ' ], $ cityInput ) !== false ;
215+ });
216+
210217 if (count ($ provinceMatches ) > 1 ) {
211218 foreach ($ regionMatches as $ regionMatch ) {
212219 $ pidPrefix = substr ($ regionMatch ['pid ' ], 0 , 2 );
@@ -295,7 +302,9 @@ private static function handleSingleRegionMatch(array $region, string $unknownVa
295302 */
296303 private static function handleNoRegionMatch (string $ cityInput , string $ regionInput , string $ unknownValue , array $ level1Data , array $ level2Data ): array
297304 {
298- $ cityMatches = array_filter ($ level2Data , fn ($ v ) => mb_strpos ($ v ['name ' ], $ cityInput ) !== false );
305+ $ cityMatches = array_filter ($ level2Data , function ($ v ) use ($ cityInput ) {
306+ return mb_strpos ($ v ['name ' ], $ cityInput ) !== false ;
307+ });
299308
300309 if (count ($ cityMatches ) > 0 ) {
301310 $ first = array_values ($ cityMatches )[0 ];
@@ -305,20 +314,21 @@ private static function handleNoRegionMatch(string $cityInput, string $regionInp
305314 'region ' => $ regionInput
306315 ];
307316 }
308-
309- $ provinceMatches = array_filter ( $ level1Data , fn ( $ v ) => mb_strpos ($ v ['name ' ], $ cityInput ) !== false ) ;
310-
317+ $ provinceMatches = array_filter ( $ level1Data , function ( $ v ) use ( $ cityInput ) {
318+ return mb_strpos ($ v ['name ' ], $ cityInput ) !== false ;
319+ });
311320 if (count ($ provinceMatches ) > 0 ) {
312321 foreach ($ provinceMatches as $ id => $ province ) {
313- $ citiesUnderProvince = array_filter ($ level2Data , fn ($ v ) => $ v ['pid ' ] == $ id );
322+ $ citiesUnderProvince = array_filter ($ level2Data , function ($ v ) use ($ id ) {
323+ return $ v ['pid ' ] == $ id ;
324+ });
314325 return [
315326 'province ' => $ province ['name ' ],
316327 'city ' => count ($ citiesUnderProvince ) === 0 ? '' : $ unknownValue ,
317328 'region ' => $ regionInput
318329 ];
319330 }
320331 }
321-
322332 return [
323333 'province ' => $ unknownValue ,
324334 'city ' => $ cityInput ,
0 commit comments