3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "name": "abc", "category": "new_cat", "selectedLanguage": { "de": "Deutsch", "de_status": "APPROVED" } }, { "name": "def", "category": "new_def", "selectedLanguage": { "es": "Espanol", "es_status": "APPROVED" } }, { "name": "abc", "category": "new_cat", "selectedLanguage": { "en": "English", "en_status": "APPROVED" } }]'; $result = []; foreach (json_decode($json, true) as $row) { $result[$row['name']] = !isset($result[$row['name']]) ? $row : array_replace_recursive($result[$row['name']], $row); } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/Q6lNA
function name:  (null)
number of ops:  33
compiled vars:  !0 = $json, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%0A++++%22name%22%3A+%22abc%22%2C%0A++++%22category%22%3A+%22new_cat%22%2C%0A++++%22selectedLanguage%22%3A+%7B%0A++++++++%22de%22%3A+%22Deutsch%22%2C%0A++++++++%22de_status%22%3A+%22APPROVED%22%0A++++%7D%0A%7D%2C+%7B%0A++++%22name%22%3A+%22def%22%2C%0A++++%22category%22%3A+%22new_def%22%2C%0A++++%22selectedLanguage%22%3A+%7B%0A++++++++%22es%22%3A+%22Espanol%22%2C%0A++++++++%22es_status%22%3A+%22APPROVED%22%0A++++%7D%0A%7D%2C+%7B%0A++++%22name%22%3A+%22abc%22%2C%0A++++%22category%22%3A+%22new_cat%22%2C%0A++++%22selectedLanguage%22%3A+%7B%0A++++++++%22en%22%3A+%22English%22%2C%0A++++++++%22en_status%22%3A+%22APPROVED%22%0A++++%7D%0A%7D%5D'
   26     1        ASSIGN                                                   !1, <array>
   27     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $5      
          6      > FE_RESET_R                                       $6      $5, ->25
          7    > > FE_FETCH_R                                               $6, !2, ->25
   28     8    >   FETCH_DIM_R                                      ~7      !2, 'name'
          9        FETCH_DIM_R                                      ~9      !2, 'name'
         10        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, ~9
         11        BOOL_NOT                                         ~11     ~10
         12      > JMPZ                                                     ~11, ->15
         13    >   QM_ASSIGN                                        ~12     !2
         14      > JMP                                                      ->22
         15    >   INIT_FCALL                                               'array_replace_recursive'
         16        FETCH_DIM_R                                      ~13     !2, 'name'
         17        FETCH_DIM_R                                      ~14     !1, ~13
         18        SEND_VAL                                                 ~14
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $15     
         21        QM_ASSIGN                                        ~12     $15
         22    >   ASSIGN_DIM                                               !1, ~7
         23        OP_DATA                                                  ~12
   27    24      > JMP                                                      ->7
         25    >   FE_FREE                                                  $6
   30    26        INIT_FCALL                                               'var_export'
         27        INIT_FCALL                                               'array_values'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $16     
         30        SEND_VAR                                                 $16
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.28 ms | 1018 KiB | 17 Q