3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result='[{"receipt": "abc","ordered":{"food":"set A","drink":"coke"}},{"receipt":"123","ordered":{"food":"set E","drink":"pepsi"}},{"receipt":"abc","ordered":{"food":"set B","drink":"7-up"}}]'; $jsondecoded = json_decode($result); for ($i = 0; $i < sizeof($jsondecoded); $i++) { $ordered[] = json_encode($jsondecoded[$i]->{'ordered'}); //$ordered[$i] = str_replace("", '', $ordered[$i]); $ordered[$i] = trim($ordered[$i], '"'); //$eatway[] = $jsondecoded[$i]->{'diningway'}; $receipt[] = $jsondecoded[$i]->{'receipt'}; } for ($j = 0; $j < sizeof($ordered); $j++) { $food[] = json_decode($ordered[$j])->{'food'}; $drink[] = json_decode($ordered[$j])->{'drink'}; } $out = array(); for ($i = 0; $i < sizeof($receipt); $i++) { if(empty($out)){ $out[0]->{'receipt'} = $receipt[$i]; $out[0]->{'order'} = '('.$food[$i].')'; $checkint[] = 0; } else if (!empty($out)){ for ($j = 0; $j < sizeof($out); $j++) { if ($receipt[$i]==$out[$j]->{'receipt'} && in_array($i, $checkint)) { $out[$j]->{'order'} = $out[$j]->{'order'}.','.'('.$food[$i].')'; } else if ($j + 1 == sizeof($out)) { $out[sizeof($out)]->{'receipt'} = $receipt[$i]; $out[sizeof($out)-1]->{'order'} = '('.$food[$i].')'; } } } } for ($i = 0; $i < sizeof($out); $i++) { echo $out[$i]->{'receipt'}; echo $out[$i]->{'order'}; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 7
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 31
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 116
Branch analysis from position: 116
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 52
Branch analysis from position: 119
1 jumps found. (Code = 42) Position 1 = 128
Branch analysis from position: 128
2 jumps found. (Code = 44) Position 1 = 131, Position 2 = 121
Branch analysis from position: 131
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 131, Position 2 = 121
Branch analysis from position: 131
Branch analysis from position: 121
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 67
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
2 jumps found. (Code = 44) Position 1 = 119, Position 2 = 52
Branch analysis from position: 119
Branch analysis from position: 52
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 115
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 112
Branch analysis from position: 112
2 jumps found. (Code = 44) Position 1 = 115, Position 2 = 72
Branch analysis from position: 115
Branch analysis from position: 72
2 jumps found. (Code = 46) Position 1 = 77, Position 2 = 82
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 94
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 111
Branch analysis from position: 111
2 jumps found. (Code = 44) Position 1 = 115, Position 2 = 72
Branch analysis from position: 115
Branch analysis from position: 72
Branch analysis from position: 94
2 jumps found. (Code = 43) Position 1 = 98, Position 2 = 111
Branch analysis from position: 98
2 jumps found. (Code = 44) Position 1 = 115, Position 2 = 72
Branch analysis from position: 115
Branch analysis from position: 72
Branch analysis from position: 111
Branch analysis from position: 82
Branch analysis from position: 115
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 31
Branch analysis from position: 49
Branch analysis from position: 31
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 7
Branch analysis from position: 29
Branch analysis from position: 7
filename:       /in/XJkF9
function name:  (null)
number of ops:  132
compiled vars:  !0 = $result, !1 = $jsondecoded, !2 = $i, !3 = $ordered, !4 = $receipt, !5 = $j, !6 = $food, !7 = $drink, !8 = $out, !9 = $checkint
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%22receipt%22%3A+%22abc%22%2C%22ordered%22%3A%7B%22food%22%3A%22set+A%22%2C%22drink%22%3A%22coke%22%7D%7D%2C%7B%22receipt%22%3A%22123%22%2C%22ordered%22%3A%7B%22food%22%3A%22set+E%22%2C%22drink%22%3A%22pepsi%22%7D%7D%2C%7B%22receipt%22%3A%22abc%22%2C%22ordered%22%3A%7B%22food%22%3A%22set+B%22%2C%22drink%22%3A%227-up%22%7D%7D%5D'
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $11     
          4        ASSIGN                                                   !1, $11
    5     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->26
    6     7    >   INIT_FCALL                                               'json_encode'
          8        FETCH_DIM_R                                      ~15     !1, !2
          9        FETCH_OBJ_R                                      ~16     ~15, 'ordered'
         10        SEND_VAL                                                 ~16
         11        DO_ICALL                                         $17     
         12        ASSIGN_DIM                                               !3
         13        OP_DATA                                                  $17
    8    14        INIT_FCALL                                               'trim'
         15        FETCH_DIM_R                                      ~19     !3, !2
         16        SEND_VAL                                                 ~19
         17        SEND_VAL                                                 '%22'
         18        DO_ICALL                                         $20     
         19        ASSIGN_DIM                                               !3, !2
         20        OP_DATA                                                  $20
   10    21        FETCH_DIM_R                                      ~22     !1, !2
         22        FETCH_OBJ_R                                      ~23     ~22, 'receipt'
         23        ASSIGN_DIM                                               !4
         24        OP_DATA                                                  ~23
    5    25        PRE_INC                                                  !2
         26    >   COUNT                                            ~25     !1
         27        IS_SMALLER                                               !2, ~25
         28      > JMPNZ                                                    ~26, ->7
   12    29    >   ASSIGN                                                   !5, 0
         30      > JMP                                                      ->46
   13    31    >   INIT_FCALL                                               'json_decode'
         32        FETCH_DIM_R                                      ~29     !3, !5
         33        SEND_VAL                                                 ~29
         34        DO_ICALL                                         $30     
         35        FETCH_OBJ_R                                      ~31     $30, 'food'
         36        ASSIGN_DIM                                               !6
         37        OP_DATA                                                  ~31
   14    38        INIT_FCALL                                               'json_decode'
         39        FETCH_DIM_R                                      ~33     !3, !5
         40        SEND_VAL                                                 ~33
         41        DO_ICALL                                         $34     
         42        FETCH_OBJ_R                                      ~35     $34, 'drink'
         43        ASSIGN_DIM                                               !7
         44        OP_DATA                                                  ~35
   12    45        PRE_INC                                                  !5
         46    >   COUNT                                            ~37     !3
         47        IS_SMALLER                                               !5, ~37
         48      > JMPNZ                                                    ~38, ->31
   16    49    >   ASSIGN                                                   !8, <array>
   17    50        ASSIGN                                                   !2, 0
         51      > JMP                                                      ->116
   18    52    >   ISSET_ISEMPTY_CV                                         !8
         53      > JMPZ                                                     ~41, ->67
   19    54    >   FETCH_DIM_R                                      ~44     !4, !2
         55        FETCH_DIM_W                                      $42     !8, 0
         56        ASSIGN_OBJ                                               $42, 'receipt'
         57        OP_DATA                                                  ~44
   20    58        FETCH_DIM_R                                      ~47     !6, !2
         59        CONCAT                                           ~48     '%28', ~47
         60        CONCAT                                           ~49     ~48, '%29'
         61        FETCH_DIM_W                                      $45     !8, 0
         62        ASSIGN_OBJ                                               $45, 'order'
         63        OP_DATA                                                  ~49
   21    64        ASSIGN_DIM                                               !9
         65        OP_DATA                                                  0
         66      > JMP                                                      ->115
   23    67    >   ISSET_ISEMPTY_CV                                 ~51     !8
         68        BOOL_NOT                                         ~52     ~51
         69      > JMPZ                                                     ~52, ->115
   24    70    >   ASSIGN                                                   !5, 0
         71      > JMP                                                      ->112
   25    72    >   FETCH_DIM_R                                      ~54     !4, !2
         73        FETCH_DIM_R                                      ~55     !8, !5
         74        FETCH_OBJ_R                                      ~56     ~55, 'receipt'
         75        IS_EQUAL                                         ~57     ~54, ~56
         76      > JMPZ_EX                                          ~57     ~57, ->82
         77    >   INIT_FCALL                                               'in_array'
         78        SEND_VAR                                                 !2
         79        SEND_VAR                                                 !9
         80        DO_ICALL                                         $58     
         81        BOOL                                             ~57     $58
         82    > > JMPZ                                                     ~57, ->94
   26    83    >   FETCH_DIM_R                                      ~61     !8, !5
         84        FETCH_OBJ_R                                      ~62     ~61, 'order'
         85        CONCAT                                           ~63     ~62, '%2C'
         86        CONCAT                                           ~64     ~63, '%28'
         87        FETCH_DIM_R                                      ~65     !6, !2
         88        CONCAT                                           ~66     ~64, ~65
         89        CONCAT                                           ~67     ~66, '%29'
         90        FETCH_DIM_W                                      $59     !8, !5
         91        ASSIGN_OBJ                                               $59, 'order'
         92        OP_DATA                                                  ~67
         93      > JMP                                                      ->111
   28    94    >   ADD                                              ~68     !5, 1
         95        COUNT                                            ~69     !8
         96        IS_EQUAL                                                 ~68, ~69
         97      > JMPZ                                                     ~70, ->111
   29    98    >   COUNT                                            ~71     !8
         99        FETCH_DIM_R                                      ~74     !4, !2
        100        FETCH_DIM_W                                      $72     !8, ~71
        101        ASSIGN_OBJ                                               $72, 'receipt'
        102        OP_DATA                                                  ~74
   30   103        COUNT                                            ~75     !8
        104        SUB                                              ~76     ~75, 1
        105        FETCH_DIM_R                                      ~79     !6, !2
        106        CONCAT                                           ~80     '%28', ~79
        107        CONCAT                                           ~81     ~80, '%29'
        108        FETCH_DIM_W                                      $77     !8, ~76
        109        ASSIGN_OBJ                                               $77, 'order'
        110        OP_DATA                                                  ~81
   24   111    >   PRE_INC                                                  !5
        112    >   COUNT                                            ~83     !8
        113        IS_SMALLER                                               !5, ~83
        114      > JMPNZ                                                    ~84, ->72
   17   115    >   PRE_INC                                                  !2
        116    >   COUNT                                            ~86     !4
        117        IS_SMALLER                                               !2, ~86
        118      > JMPNZ                                                    ~87, ->52
   36   119    >   ASSIGN                                                   !2, 0
        120      > JMP                                                      ->128
   37   121    >   FETCH_DIM_R                                      ~89     !8, !2
        122        FETCH_OBJ_R                                      ~90     ~89, 'receipt'
        123        ECHO                                                     ~90
   38   124        FETCH_DIM_R                                      ~91     !8, !2
        125        FETCH_OBJ_R                                      ~92     ~91, 'order'
        126        ECHO                                                     ~92
   36   127        PRE_INC                                                  !2
        128    >   COUNT                                            ~94     !8
        129        IS_SMALLER                                               !2, ~94
        130      > JMPNZ                                                    ~95, ->121
   39   131    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
205.14 ms | 1408 KiB | 21 Q