3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_map_custom($array, $callable) { $result = []; foreach($array as $item) { $result[] = $callable($item); } return $result; } $arr = [1, 2, 3, 4]; $newArr = array_map_custom( $arr, function($x){ return $x*$x; }); print_r($newArr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYW1r
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr, !1 = $newArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'array_map_custom'
   14     2        SEND_VAR                                                 !0
   15     3        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   17     4        SEND_VAL                                                 ~3
   13     5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   19     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYW1r
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        MUL                                              ~1      !0, !0
          2      > RETURN                                                   ~1
   17     3*     > RETURN                                                   null

End of Dynamic Function 0

Function array_map_custom:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/hYW1r
function name:  array_map_custom
number of ops:  14
compiled vars:  !0 = $array, !1 = $callable, !2 = $result, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3      > FE_RESET_R                                       $5      !0, ->11
          4    > > FE_FETCH_R                                               $5, !3, ->11
    6     5    >   INIT_DYNAMIC_CALL                                        !1
          6        SEND_VAR_EX                                              !3
          7        DO_FCALL                                      0  $7      
          8        ASSIGN_DIM                                               !2
          9        OP_DATA                                                  $7
    5    10      > JMP                                                      ->4
         11    >   FE_FREE                                                  $5
    8    12      > RETURN                                                   !2
    9    13*     > RETURN                                                   null

End of function array_map_custom

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.59 ms | 1001 KiB | 15 Q