3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '{ "menu__item_name":"test1|test2|test3", "menu_item_price":"775.00|100|30", "menu_item_description":"Melon Ball |Big mac|cocke", "menu_item_sort":"1|3|2", "menu_item_status":"1|1|1", "menu_item_display":"1|1|0" }'; //print_r(json_decode($str)); $strArr = json_decode($str); /*$menu__item_name = $strArr->menu__item_name; $menu_item_price = $strArr->menu_item_price; $menu_item_description = $strArr->menu_item_description; $menu_item_sort = $strArr->menu_item_sort; $menu_item_status = $strArr->menu_item_status; $menu_item_display = $strArr->menu_item_display;*/ $menu__item_name_arr = explode('|', $strArr->menu__item_name); $menu_item_price_arr = explode('|', $strArr->menu_item_price); $menu_item_description_arr = explode('|', $strArr->menu_item_description); $menu_item_sort_arr = explode('|', $strArr->menu_item_sort); $menu_item_status_arr = explode('|', $strArr->menu_item_status); $menu_item_display_arr = explode('|', $strArr->menu_item_display); foreach($menu_item_sort_arr as $item){ $key = $item - 1; $finalArr['menu__item_name'][] = isset($menu__item_name_arr[$key]) ? $menu__item_name_arr[$key] : '' ; $finalArr['menu_item_price'][] = isset($menu_item_price_arr[$key]) ? $menu_item_price_arr[$key] : '' ; $finalArr['menu_item_description'][] = isset($menu_item_description_arr[$key]) ? $menu_item_description_arr[$key] : ''; $finalArr['menu_item_sort'][] = isset($menu_item_sort_arr[$key]) ? $menu_item_sort_arr[$key] : '' ; $finalArr['menu_item_status'][] = isset($menu_item_status_arr[$key]) ? $menu_item_status_arr[$key] : '' ; $finalArr['menu_item_display'][] = isset($menu_item_display_arr[$key]) ? $menu_item_display_arr[$key] : ''; } foreach($finalArr as $k => $arr){ $newArr[$k] = implode('|', $arr); } $sortedJson = (object) $newArr; print_r($sortedJson); echo json_encode($sortedJson);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 100
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 100
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 50
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 59
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 68
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 77
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 86
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 95
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 95
Branch analysis from position: 92
Branch analysis from position: 95
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 86
Branch analysis from position: 83
Branch analysis from position: 86
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 77
Branch analysis from position: 74
Branch analysis from position: 77
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 68
Branch analysis from position: 65
Branch analysis from position: 68
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 59
Branch analysis from position: 56
Branch analysis from position: 59
Branch analysis from position: 100
2 jumps found. (Code = 77) Position 1 = 102, Position 2 = 111
Branch analysis from position: 102
2 jumps found. (Code = 78) Position 1 = 103, Position 2 = 111
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 111
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 111
Branch analysis from position: 100
filename:       /in/HCWV5
function name:  (null)
number of ops:  122
compiled vars:  !0 = $str, !1 = $strArr, !2 = $menu__item_name_arr, !3 = $menu_item_price_arr, !4 = $menu_item_description_arr, !5 = $menu_item_sort_arr, !6 = $menu_item_status_arr, !7 = $menu_item_display_arr, !8 = $item, !9 = $key, !10 = $finalArr, !11 = $arr, !12 = $k, !13 = $newArr, !14 = $sortedJson
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++%22menu__item_name%22%3A%22test1%7Ctest2%7Ctest3%22%2C%0A++%22menu_item_price%22%3A%22775.00%7C100%7C30%22%2C%0A++%22menu_item_description%22%3A%22Melon+Ball+%7CBig+mac%7Ccocke%22%2C%0A++%22menu_item_sort%22%3A%221%7C3%7C2%22%2C%0A++%22menu_item_status%22%3A%221%7C1%7C1%22%2C%0A++%22menu_item_display%22%3A%221%7C1%7C0%22%0A%7D'
   12     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $16     
          4        ASSIGN                                                   !1, $16
   20     5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%7C'
          7        FETCH_OBJ_R                                      ~18     !1, 'menu__item_name'
          8        SEND_VAL                                                 ~18
          9        DO_ICALL                                         $19     
         10        ASSIGN                                                   !2, $19
   21    11        INIT_FCALL                                               'explode'
         12        SEND_VAL                                                 '%7C'
         13        FETCH_OBJ_R                                      ~21     !1, 'menu_item_price'
         14        SEND_VAL                                                 ~21
         15        DO_ICALL                                         $22     
         16        ASSIGN                                                   !3, $22
   22    17        INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '%7C'
         19        FETCH_OBJ_R                                      ~24     !1, 'menu_item_description'
         20        SEND_VAL                                                 ~24
         21        DO_ICALL                                         $25     
         22        ASSIGN                                                   !4, $25
   23    23        INIT_FCALL                                               'explode'
         24        SEND_VAL                                                 '%7C'
         25        FETCH_OBJ_R                                      ~27     !1, 'menu_item_sort'
         26        SEND_VAL                                                 ~27
         27        DO_ICALL                                         $28     
         28        ASSIGN                                                   !5, $28
   24    29        INIT_FCALL                                               'explode'
         30        SEND_VAL                                                 '%7C'
         31        FETCH_OBJ_R                                      ~30     !1, 'menu_item_status'
         32        SEND_VAL                                                 ~30
         33        DO_ICALL                                         $31     
         34        ASSIGN                                                   !6, $31
   25    35        INIT_FCALL                                               'explode'
         36        SEND_VAL                                                 '%7C'
         37        FETCH_OBJ_R                                      ~33     !1, 'menu_item_display'
         38        SEND_VAL                                                 ~33
         39        DO_ICALL                                         $34     
         40        ASSIGN                                                   !7, $34
   27    41      > FE_RESET_R                                       $36     !5, ->100
         42    > > FE_FETCH_R                                               $36, !8, ->100
   28    43    >   SUB                                              ~37     !8, 1
         44        ASSIGN                                                   !9, ~37
   29    45        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !9
         46      > JMPZ                                                     ~41, ->50
         47    >   FETCH_DIM_R                                      ~42     !2, !9
         48        QM_ASSIGN                                        ~43     ~42
         49      > JMP                                                      ->51
         50    >   QM_ASSIGN                                        ~43     ''
         51    >   FETCH_DIM_W                                      $39     !10, 'menu__item_name'
         52        ASSIGN_DIM                                               $39
         53        OP_DATA                                                  ~43
   30    54        ISSET_ISEMPTY_DIM_OBJ                         0          !3, !9
         55      > JMPZ                                                     ~46, ->59
         56    >   FETCH_DIM_R                                      ~47     !3, !9
         57        QM_ASSIGN                                        ~48     ~47
         58      > JMP                                                      ->60
         59    >   QM_ASSIGN                                        ~48     ''
         60    >   FETCH_DIM_W                                      $44     !10, 'menu_item_price'
         61        ASSIGN_DIM                                               $44
         62        OP_DATA                                                  ~48
   31    63        ISSET_ISEMPTY_DIM_OBJ                         0          !4, !9
         64      > JMPZ                                                     ~51, ->68
         65    >   FETCH_DIM_R                                      ~52     !4, !9
         66        QM_ASSIGN                                        ~53     ~52
         67      > JMP                                                      ->69
         68    >   QM_ASSIGN                                        ~53     ''
         69    >   FETCH_DIM_W                                      $49     !10, 'menu_item_description'
         70        ASSIGN_DIM                                               $49
         71        OP_DATA                                                  ~53
   32    72        ISSET_ISEMPTY_DIM_OBJ                         0          !5, !9
         73      > JMPZ                                                     ~56, ->77
         74    >   FETCH_DIM_R                                      ~57     !5, !9
         75        QM_ASSIGN                                        ~58     ~57
         76      > JMP                                                      ->78
         77    >   QM_ASSIGN                                        ~58     ''
         78    >   FETCH_DIM_W                                      $54     !10, 'menu_item_sort'
         79        ASSIGN_DIM                                               $54
         80        OP_DATA                                                  ~58
   33    81        ISSET_ISEMPTY_DIM_OBJ                         0          !6, !9
         82      > JMPZ                                                     ~61, ->86
         83    >   FETCH_DIM_R                                      ~62     !6, !9
         84        QM_ASSIGN                                        ~63     ~62
         85      > JMP                                                      ->87
         86    >   QM_ASSIGN                                        ~63     ''
         87    >   FETCH_DIM_W                                      $59     !10, 'menu_item_status'
         88        ASSIGN_DIM                                               $59
         89        OP_DATA                                                  ~63
   34    90        ISSET_ISEMPTY_DIM_OBJ                         0          !7, !9
         91      > JMPZ                                                     ~66, ->95
         92    >   FETCH_DIM_R                                      ~67     !7, !9
         93        QM_ASSIGN                                        ~68     ~67
         94      > JMP                                                      ->96
         95    >   QM_ASSIGN                                        ~68     ''
         96    >   FETCH_DIM_W                                      $64     !10, 'menu_item_display'
         97        ASSIGN_DIM                                               $64
         98        OP_DATA                                                  ~68
   27    99      > JMP                                                      ->42
        100    >   FE_FREE                                                  $36
   37   101      > FE_RESET_R                                       $69     !10, ->111
        102    > > FE_FETCH_R                                       ~70     $69, !11, ->111
        103    >   ASSIGN                                                   !12, ~70
   38   104        INIT_FCALL                                               'implode'
        105        SEND_VAL                                                 '%7C'
        106        SEND_VAR                                                 !11
        107        DO_ICALL                                         $73     
        108        ASSIGN_DIM                                               !13, !12
        109        OP_DATA                                                  $73
   37   110      > JMP                                                      ->102
        111    >   FE_FREE                                                  $69
   40   112        CAST                                          8  ~74     !13
        113        ASSIGN                                                   !14, ~74
   41   114        INIT_FCALL                                               'print_r'
        115        SEND_VAR                                                 !14
        116        DO_ICALL                                                 
   42   117        INIT_FCALL                                               'json_encode'
        118        SEND_VAR                                                 !14
        119        DO_ICALL                                         $77     
        120        ECHO                                                     $77
        121      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.45 ms | 1015 KiB | 18 Q