3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruit = array(); $fruit[] = array('id' => 1, 'name' => 'Banana 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 1, 'name' => 'Pear 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 1, 'name' => 'Mango 1', 'pieces' => get_pieces(1)); $fruit[] = array('id' => 2, 'name' => 'Banana 2', 'pieces' => get_pieces(2)); $fruit[] = array('id' => 2, 'name' => 'Pear 2', 'pieces' => get_pieces(2)); $fruit[] = array('id' => 2, 'name' => 'Mango 2', 'pieces' => get_pieces(2)); function get_pieces($id) { $pieces = array(); switch ($id) { case 1: $pieces[] = array('number' => 1); $pieces[] = array('number' => 2); break; case 2: $pieces[] = array('number' => 3); $pieces[] = array('number' => 4, 'qwerty' => 1); break; } return $pieces; } print json_encode(array('fruit' => $fruit));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kUKff
function name:  (null)
number of ops:  55
compiled vars:  !0 = $fruit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_ARRAY                                       ~3      1, 'id'
          2        ADD_ARRAY_ELEMENT                                ~3      'Banana+1', 'name'
          3        INIT_FCALL_BY_NAME                                       'get_pieces'
          4        SEND_VAL_EX                                              1
          5        DO_FCALL                                      0  $4      
          6        ADD_ARRAY_ELEMENT                                ~3      $4, 'pieces'
          7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  ~3
    6     9        INIT_ARRAY                                       ~6      1, 'id'
         10        ADD_ARRAY_ELEMENT                                ~6      'Pear+1', 'name'
         11        INIT_FCALL_BY_NAME                                       'get_pieces'
         12        SEND_VAL_EX                                              1
         13        DO_FCALL                                      0  $7      
         14        ADD_ARRAY_ELEMENT                                ~6      $7, 'pieces'
         15        ASSIGN_DIM                                               !0
         16        OP_DATA                                                  ~6
    7    17        INIT_ARRAY                                       ~9      1, 'id'
         18        ADD_ARRAY_ELEMENT                                ~9      'Mango+1', 'name'
         19        INIT_FCALL_BY_NAME                                       'get_pieces'
         20        SEND_VAL_EX                                              1
         21        DO_FCALL                                      0  $10     
         22        ADD_ARRAY_ELEMENT                                ~9      $10, 'pieces'
         23        ASSIGN_DIM                                               !0
         24        OP_DATA                                                  ~9
    9    25        INIT_ARRAY                                       ~12     2, 'id'
         26        ADD_ARRAY_ELEMENT                                ~12     'Banana+2', 'name'
         27        INIT_FCALL_BY_NAME                                       'get_pieces'
         28        SEND_VAL_EX                                              2
         29        DO_FCALL                                      0  $13     
         30        ADD_ARRAY_ELEMENT                                ~12     $13, 'pieces'
         31        ASSIGN_DIM                                               !0
         32        OP_DATA                                                  ~12
   10    33        INIT_ARRAY                                       ~15     2, 'id'
         34        ADD_ARRAY_ELEMENT                                ~15     'Pear+2', 'name'
         35        INIT_FCALL_BY_NAME                                       'get_pieces'
         36        SEND_VAL_EX                                              2
         37        DO_FCALL                                      0  $16     
         38        ADD_ARRAY_ELEMENT                                ~15     $16, 'pieces'
         39        ASSIGN_DIM                                               !0
         40        OP_DATA                                                  ~15
   11    41        INIT_ARRAY                                       ~18     2, 'id'
         42        ADD_ARRAY_ELEMENT                                ~18     'Mango+2', 'name'
         43        INIT_FCALL_BY_NAME                                       'get_pieces'
         44        SEND_VAL_EX                                              2
         45        DO_FCALL                                      0  $19     
         46        ADD_ARRAY_ELEMENT                                ~18     $19, 'pieces'
         47        ASSIGN_DIM                                               !0
         48        OP_DATA                                                  ~18
   33    49        INIT_FCALL                                               'json_encode'
         50        INIT_ARRAY                                       ~20     !0, 'fruit'
         51        SEND_VAL                                                 ~20
         52        DO_ICALL                                         $21     
         53        ECHO                                                     $21
         54      > RETURN                                                   1

Function get_pieces:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
filename:       /in/kUKff
function name:  get_pieces
number of ops:  19
compiled vars:  !0 = $id, !1 = $pieces
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, <array>
   19     2        IS_EQUAL                                                 !0, 1
          3      > JMPNZ                                                    ~3, ->7
   24     4    >   IS_EQUAL                                                 !0, 2
          5      > JMPNZ                                                    ~3, ->12
          6    > > JMP                                                      ->17
   20     7    >   ASSIGN_DIM                                               !1
          8        OP_DATA                                                  <array>
   21     9        ASSIGN_DIM                                               !1
         10        OP_DATA                                                  <array>
   22    11      > JMP                                                      ->17
   25    12    >   ASSIGN_DIM                                               !1
         13        OP_DATA                                                  <array>
   26    14        ASSIGN_DIM                                               !1
         15        OP_DATA                                                  <array>
   27    16      > JMP                                                      ->17
   30    17    > > RETURN                                                   !1
   31    18*     > RETURN                                                   null

End of function get_pieces

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.7 ms | 1442 KiB | 14 Q