@@ -250,8 +250,6 @@ private function processSegment($segment, &$xmlMap, $segmentIdx, &$errors = null
250
250
$ attributes = $ xmlMap [$ id ]['attributes ' ];
251
251
$ details_desc = $ xmlMap [$ id ]['details ' ];
252
252
253
- $ entryCount = [];
254
-
255
253
$ jsonelements = ["segmentIdx " => $ segmentIdx , "segmentCode " => $ id ];
256
254
foreach ($ segment as $ idx => $ detail ) {
257
255
$ n = $ idx - 1 ;
@@ -271,12 +269,6 @@ private function processSegment($segment, &$xmlMap, $segmentIdx, &$errors = null
271
269
272
270
$ d_desc_attr = $ details_desc [$ n ]['attributes ' ];
273
271
274
- if (!array_key_exists ($ d_desc_attr ['name ' ], $ entryCount )) {
275
- $ entryCount [$ d_desc_attr ['name ' ]] = 0 ;
276
- }
277
-
278
- $ entryCount [$ d_desc_attr ['name ' ]]++;
279
-
280
272
$ jsoncomposite = [];
281
273
if (isset ($ details_desc [$ n ]['details ' ]) && $ detail !== '' ) {
282
274
$ sub_details_desc = $ details_desc [$ n ]['details ' ];
@@ -309,15 +301,12 @@ private function processSegment($segment, &$xmlMap, $segmentIdx, &$errors = null
309
301
$ jsoncomposite = $ detail ;
310
302
}
311
303
312
- if ($ entryCount [ $ d_desc_attr ['name ' ]] === 1 ) {
313
- $ jsonelements [$ d_desc_attr ['name ' ]] = $ jsoncomposite ;
304
+ if (array_key_exists ( $ d_desc_attr ['name ' ], $ jsonelements ) ) {
305
+ $ jsonelements [$ d_desc_attr ['name ' ]. $ n ] = $ jsoncomposite ;
314
306
} else {
315
- if ($ entryCount [$ d_desc_attr ['name ' ]] === 2 ) {
316
- $ jsonelements [$ d_desc_attr ['name ' ]] = [$ jsonelements [$ d_desc_attr ['name ' ]]];
317
- }
318
-
319
- $ jsonelements [$ d_desc_attr ['name ' ]][] = $ jsoncomposite ;
307
+ $ jsonelements [$ d_desc_attr ['name ' ]] = $ jsoncomposite ;
320
308
}
309
+
321
310
}
322
311
$ jsonsegment ['key ' ] = $ attributes ['name ' ];
323
312
$ jsonsegment ['value ' ] = $ jsonelements ;
0 commit comments