3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValues(&$egElement, $property, $option = NULL) { if(is_array($egElement) === FALSE) { return array(); } if(is_int($option) and $option > 1) { $values = array(); foreach($egElement as $key => $egSubElement) { $values = array_merge( $values, getValues($egSubElement, $property, $option - 1) ); } return $values; } if( is_string($option) or $option === TRUE ) { $values = array(); foreach($egElement as $key => $eElement) { if(array_key_exists($property, $eElement)) { if(is_string($option)) { $values[$key] = call_user_func_array($option, array($eElement[$property])); } else if($option === TRUE) { $values[$key] = &$egElement[$key][$property]; } } } reset($egElement); } else { return array_column($egElement, $property); } return $values; } $eg = array( 1 => array('id' => 4, 'dragon' => array('toto' => 5, 'titi' => 6)), 2 => array('id' => 5, 'dragon' => array('toto' => 5, 'titi' => 6)), 3 => array('id' => 6, 'dragon' => array('toto' => 5, 'titi' => 6)), 4 => array('id' => 7, 'dragon' => array('toto' => 5, 'titi' => 6)), 5 => array('id' => 8, 'dragon' => array('toto' => 5, 'titi' => 6)), 6 => array('id' => 9, 'dragon' => array('toto' => 5, 'titi' => 6)), 7 => array('id' => 10, 'dragon' => array('toto' => 5, 'titi' => 6)), 8 => array('id' => 11, 'dragon' => array('toto' => 5, 'titi' => 6)), ); var_dump(getValues($eg, 'dragon'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wi5h9
function name:  (null)
number of ops:  9
compiled vars:  !0 = $eg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ASSIGN                                                   !0, <array>
   63     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getvalues'
          3        SEND_REF                                                 !0
          4        SEND_VAL                                                 'dragon'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function getvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 30
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 30
2 jumps found. (Code = 47) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 65
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 60
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 60
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 59
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 52
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 59
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 59
Branch analysis from position: 59
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 11
filename:       /in/Wi5h9
function name:  getValues
number of ops:  72
compiled vars:  !0 = $egElement, !1 = $property, !2 = $option, !3 = $values, !4 = $egSubElement, !5 = $key, !6 = $eElement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    5     3        TYPE_CHECK                                  128  ~7      !0
          4        TYPE_CHECK                                    4          ~7
          5      > JMPZ                                                     ~8, ->7
    6     6    > > RETURN                                                   <array>
    9     7    >   TYPE_CHECK                                   16  ~9      !2
          8      > JMPZ_EX                                          ~9      ~9, ->11
          9    >   IS_SMALLER                                       ~10     1, !2
         10        BOOL                                             ~9      ~10
         11    > > JMPZ                                                     ~9, ->30
   11    12    >   ASSIGN                                                   !3, <array>
   13    13      > FE_RESET_R                                       $12     !0, ->28
         14    > > FE_FETCH_R                                       ~13     $12, !4, ->28
         15    >   ASSIGN                                                   !5, ~13
   14    16        INIT_FCALL                                               'array_merge'
   15    17        SEND_VAR                                                 !3
   16    18        INIT_FCALL_BY_NAME                                       'getValues'
         19        SEND_VAR_EX                                              !4
         20        SEND_VAR_EX                                              !1
         21        SUB                                              ~15     !2, 1
         22        SEND_VAL_EX                                              ~15
         23        DO_FCALL                                      0  $16     
         24        SEND_VAR                                                 $16
         25        DO_ICALL                                         $17     
   14    26        ASSIGN                                                   !3, $17
   13    27      > JMP                                                      ->14
         28    >   FE_FREE                                                  $12
   20    29      > RETURN                                                   !3
   26    30    >   TYPE_CHECK                                   64  ~19     !2
         31      > JMPNZ_EX                                         ~19     ~19, ->34
   27    32    >   TYPE_CHECK                                    8  ~20     !2
         33        BOOL                                             ~19     ~20
         34    > > JMPZ                                                     ~19, ->65
   30    35    >   ASSIGN                                                   !3, <array>
   32    36      > FE_RESET_R                                       $22     !0, ->60
         37    > > FE_FETCH_R                                       ~23     $22, !6, ->60
         38    >   ASSIGN                                                   !5, ~23
   33    39        ARRAY_KEY_EXISTS                                         !1, !6
         40      > JMPZ                                                     ~25, ->59
   34    41    >   TYPE_CHECK                                   64          !2
         42      > JMPZ                                                     ~26, ->52
   35    43    >   INIT_USER_CALL                                0          'call_user_func_array', !2
         44        FETCH_DIM_R                                      ~28     !6, !1
         45        INIT_ARRAY                                       ~29     ~28
         46        SEND_ARRAY                                               ~29
         47        CHECK_UNDEF_ARGS                                         
         48        DO_FCALL                                      0  $30     
         49        ASSIGN_DIM                                               !3, !5
         50        OP_DATA                                                  $30
         51      > JMP                                                      ->59
   36    52    >   TYPE_CHECK                                    8          !2
         53      > JMPZ                                                     ~31, ->59
   37    54    >   FETCH_DIM_W                                      $33     !0, !5
         55        FETCH_DIM_W                                      $34     $33, !1
         56        MAKE_REF                                         $35     $34
         57        FETCH_DIM_W                                      $32     !3, !5
         58        ASSIGN_REF                                               $32, $35
   32    59    > > JMP                                                      ->37
         60    >   FE_FREE                                                  $22
   42    61        INIT_FCALL                                               'reset'
         62        SEND_REF                                                 !0
         63        DO_ICALL                                                 
         64      > JMP                                                      ->70
   45    65    >   INIT_FCALL                                               'array_column'
         66        SEND_VAR                                                 !0
         67        SEND_VAR                                                 !1
         68        DO_ICALL                                         $38     
         69      > RETURN                                                   $38
   48    70    > > RETURN                                                   !3
   50    71*     > RETURN                                                   null

End of function getvalues

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.98 ms | 1406 KiB | 22 Q