3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [2,3,4,5]; $index = "a"; $arrayB = array_map(function ($element) { $index++; return array($index => $element); }, $array); print_r($arrayB);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jU0Dh
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $index, !2 = $arrayB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 'a'
    6     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FjU0Dh%3A6%240'
    9     4        SEND_VAL                                                 ~5
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
    6     7        ASSIGN                                                   !2, $6
   11     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FjU0Dh%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jU0Dh
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $element, !1 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        PRE_INC                                                  !1
    8     2        INIT_ARRAY                                       ~3      !0, !1
          3      > RETURN                                                   ~3
    9     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FjU0Dh%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.67 ms | 1395 KiB | 17 Q