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; } $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]; } else { $values[$key] = $eElement[$property]; } } } reset($egElement); return $values; } $egElement = array(); for($i=0;$i<1000000;$i++) { $egElement[] = array('id' => (int)rand(0,100)); } $m = memory_get_usage(true); $mm = memory_get_peak_usage(true); $t = microtime(true); getValues($egElement, 'id'); echo "Memory: ".(memory_get_usage(true) - $m)." octets\n"; echo "Max Memory: ".(memory_get_peak_usage(true) - $mm)." octets\n"; echo "Time: ".(microtime(true) - $t)." secondes\n"; $m = memory_get_usage(true); $mm = memory_get_peak_usage(true); $t = microtime(true); array_column($egElement, 'id'); echo "Memory: ".(memory_get_usage(true) - $m)." octets\n"; echo "Max Memory: ".(memory_get_peak_usage(true) - $mm)." octets\n"; echo "Time: ".(microtime(true) - $t)." secondes\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
Branch analysis from position: 3
filename:       /in/ZAmgD
function name:  (null)
number of ops:  89
compiled vars:  !0 = $egElement, !1 = $i, !2 = $m, !3 = $mm, !4 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                   !0, <array>
   31     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->12
   32     3    >   INIT_FCALL                                               'rand'
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 100
          6        DO_ICALL                                         $8      
          7        CAST                                          4  ~9      $8
          8        INIT_ARRAY                                       ~10     ~9, 'id'
          9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  ~10
   31    11        PRE_INC                                                  !1
         12    >   IS_SMALLER                                               !1, 1000000
         13      > JMPNZ                                                    ~12, ->3
   35    14    >   INIT_FCALL                                               'memory_get_usage'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !2, $13
   36    18        INIT_FCALL                                               'memory_get_peak_usage'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $15     
         21        ASSIGN                                                   !3, $15
   37    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !4, $17
   39    26        INIT_FCALL                                               'getvalues'
         27        SEND_REF                                                 !0
         28        SEND_VAL                                                 'id'
         29        DO_FCALL                                      0          
   41    30        INIT_FCALL                                               'memory_get_usage'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $20     
         33        SUB                                              ~21     $20, !2
         34        CONCAT                                           ~22     'Memory%3A+', ~21
         35        CONCAT                                           ~23     ~22, '+octets%0A'
         36        ECHO                                                     ~23
   42    37        INIT_FCALL                                               'memory_get_peak_usage'
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $24     
         40        SUB                                              ~25     $24, !3
         41        CONCAT                                           ~26     'Max+Memory%3A+', ~25
         42        CONCAT                                           ~27     ~26, '+octets%0A'
         43        ECHO                                                     ~27
   43    44        INIT_FCALL                                               'microtime'
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $28     
         47        SUB                                              ~29     $28, !4
         48        CONCAT                                           ~30     'Time%3A+', ~29
         49        CONCAT                                           ~31     ~30, '+secondes%0A'
         50        ECHO                                                     ~31
   45    51        INIT_FCALL                                               'memory_get_usage'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $32     
         54        ASSIGN                                                   !2, $32
   46    55        INIT_FCALL                                               'memory_get_peak_usage'
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $34     
         58        ASSIGN                                                   !3, $34
   47    59        INIT_FCALL                                               'microtime'
         60        SEND_VAL                                                 <true>
         61        DO_ICALL                                         $36     
         62        ASSIGN                                                   !4, $36
   49    63        INIT_FCALL                                               'array_column'
         64        SEND_VAR                                                 !0
         65        SEND_VAL                                                 'id'
         66        DO_ICALL                                                 
   51    67        INIT_FCALL                                               'memory_get_usage'
         68        SEND_VAL                                                 <true>
         69        DO_ICALL                                         $39     
         70        SUB                                              ~40     $39, !2
         71        CONCAT                                           ~41     'Memory%3A+', ~40
         72        CONCAT                                           ~42     ~41, '+octets%0A'
         73        ECHO                                                     ~42
   52    74        INIT_FCALL                                               'memory_get_peak_usage'
         75        SEND_VAL                                                 <true>
         76        DO_ICALL                                         $43     
         77        SUB                                              ~44     $43, !3
         78        CONCAT                                           ~45     'Max+Memory%3A+', ~44
         79        CONCAT                                           ~46     ~45, '+octets%0A'
         80        ECHO                                                     ~46
   53    81        INIT_FCALL                                               'microtime'
         82        SEND_VAL                                                 <true>
         83        DO_ICALL                                         $47     
         84        SUB                                              ~48     $47, !4
         85        CONCAT                                           ~49     'Time%3A+', ~48
         86        CONCAT                                           ~50     ~49, '+secondes%0A'
         87        ECHO                                                     ~50
         88      > 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 = 77) Position 1 = 32, Position 2 = 59
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 59
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 58
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 47
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 55
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 58
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 11
filename:       /in/ZAmgD
function name:  getValues
number of ops:  65
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
    4     3        TYPE_CHECK                                  128  ~7      !0
          4        TYPE_CHECK                                    4          ~7
          5      > JMPZ                                                     ~8, ->7
          6    > > RETURN                                                   <array>
    6     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
    7    12    >   ASSIGN                                                   !3, <array>
    8    13      > FE_RESET_R                                       $12     !0, ->28
         14    > > FE_FETCH_R                                       ~13     $12, !4, ->28
         15    >   ASSIGN                                                   !5, ~13
    9    16        INIT_FCALL                                               'array_merge'
         17        SEND_VAR                                                 !3
         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     
         26        ASSIGN                                                   !3, $17
    8    27      > JMP                                                      ->14
         28    >   FE_FREE                                                  $12
   11    29      > RETURN                                                   !3
   14    30    >   ASSIGN                                                   !3, <array>
   15    31      > FE_RESET_R                                       $20     !0, ->59
         32    > > FE_FETCH_R                                       ~21     $20, !6, ->59
         33    >   ASSIGN                                                   !5, ~21
   16    34        ARRAY_KEY_EXISTS                                         !1, !6
         35      > JMPZ                                                     ~23, ->58
   17    36    >   TYPE_CHECK                                   64          !2
         37      > JMPZ                                                     ~24, ->47
   18    38    >   INIT_USER_CALL                                0          'call_user_func_array', !2
         39        FETCH_DIM_R                                      ~26     !6, !1
         40        INIT_ARRAY                                       ~27     ~26
         41        SEND_ARRAY                                               ~27
         42        CHECK_UNDEF_ARGS                                         
         43        DO_FCALL                                      0  $28     
         44        ASSIGN_DIM                                               !3, !5
         45        OP_DATA                                                  $28
         46      > JMP                                                      ->58
   19    47    >   TYPE_CHECK                                    8          !2
         48      > JMPZ                                                     ~29, ->55
   20    49    >   FETCH_DIM_W                                      $31     !0, !5
         50        FETCH_DIM_W                                      $32     $31, !1
         51        MAKE_REF                                         $33     $32
         52        FETCH_DIM_W                                      $30     !3, !5
         53        ASSIGN_REF                                               $30, $33
         54      > JMP                                                      ->58
   22    55    >   FETCH_DIM_R                                      ~36     !6, !1
         56        ASSIGN_DIM                                               !3, !5
         57        OP_DATA                                                  ~36
   15    58    > > JMP                                                      ->32
         59    >   FE_FREE                                                  $20
   26    60        INIT_FCALL                                               'reset'
         61        SEND_REF                                                 !0
         62        DO_ICALL                                                 
   27    63      > RETURN                                                   !3
   28    64*     > RETURN                                                   null

End of function getvalues

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.33 ms | 1411 KiB | 28 Q