3v4l.org

run code in 300+ PHP versions simultaneously
<?php $class = new stdClass; $class->properties = [new stdClass,new stdClass, new stdClass]; $class->properties[0]->name = "Anne"; $class->properties[1]->name = "Bob"; $class->properties[2]->name = "Robin"; $fieldsA = []; $fieldsB = []; if ( array_walk( $class->properties, function( $o ) use ( &$fieldsA ){ $fieldsA[] = $o->name; }) ) { echo "\nMission accomplished:\n"; var_dump($fieldsA); } $fieldsB = array_map( function( $e ) { return $e->name; },$class->properties); if (count($fieldsB) > 0) { echo "\nMission accomplished:\n"; var_dump( $fieldsB ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 54
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 40
filename:       /in/Z7Alb
function name:  (null)
number of ops:  55
compiled vars:  !0 = $class, !1 = $fieldsA, !2 = $fieldsB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    4     3        NEW                                              $7      'stdClass'
          4        DO_FCALL                                      0          
          5        INIT_ARRAY                                       ~9      $7
          6        NEW                                              $10     'stdClass'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~9      $10
          9        NEW                                              $12     'stdClass'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~9      $12
         12        ASSIGN_OBJ                                               !0, 'properties'
         13        OP_DATA                                                  ~9
    6    14        FETCH_OBJ_W                                      $14     !0, 'properties'
         15        FETCH_DIM_W                                      $15     $14, 0
         16        ASSIGN_OBJ                                               $15, 'name'
         17        OP_DATA                                                  'Anne'
    7    18        FETCH_OBJ_W                                      $17     !0, 'properties'
         19        FETCH_DIM_W                                      $18     $17, 1
         20        ASSIGN_OBJ                                               $18, 'name'
         21        OP_DATA                                                  'Bob'
    8    22        FETCH_OBJ_W                                      $20     !0, 'properties'
         23        FETCH_DIM_W                                      $21     $20, 2
         24        ASSIGN_OBJ                                               $21, 'name'
         25        OP_DATA                                                  'Robin'
   10    26        ASSIGN                                                   !1, <array>
   11    27        ASSIGN                                                   !2, <array>
   13    28        INIT_FCALL                                               'array_walk'
         29        FETCH_OBJ_W                                      $25     !0, 'properties'
         30        SEND_REF                                                 $25
         31        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7Alb%3A13%240'
         32        BIND_LEXICAL                                             ~26, !1
   15    33        SEND_VAL                                                 ~26
         34        DO_ICALL                                         $27     
         35      > JMPZ                                                     $27, ->40
   16    36    >   ECHO                                                     '%0AMission+accomplished%3A%0A'
   17    37        INIT_FCALL                                               'var_dump'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                                 
   20    40    >   INIT_FCALL                                               'array_map'
         41        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZ7Alb%3A20%241'
   22    42        SEND_VAL                                                 ~29
         43        FETCH_OBJ_R                                      ~30     !0, 'properties'
         44        SEND_VAL                                                 ~30
         45        DO_ICALL                                         $31     
   20    46        ASSIGN                                                   !2, $31
   23    47        COUNT                                            ~33     !2
         48        IS_SMALLER                                               0, ~33
         49      > JMPZ                                                     ~34, ->54
   24    50    >   ECHO                                                     '%0AMission+accomplished%3A%0A'
   25    51        INIT_FCALL                                               'var_dump'
         52        SEND_VAR                                                 !2
         53        DO_ICALL                                                 
   26    54    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZ7Alb%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7Alb
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $o, !1 = $fieldsA
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   14     2        FETCH_OBJ_R                                      ~3      !0, 'name'
          3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  ~3
   15     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7Alb%3A13%240

Function %00%7Bclosure%7D%2Fin%2FZ7Alb%3A20%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7Alb
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_OBJ_R                                      ~1      !0, 'name'
          2      > RETURN                                                   ~1
   22     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZ7Alb%3A20%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.64 ms | 948 KiB | 20 Q