3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array('id' => 1, 'name' => 'Fred'); $result = array_map_assoc( function ($key, $value) { return $value; }, $arr ); $result2 = array_map_assoc( function ($key, $value, $value2) { return "$value2 ($key: $value)"; }, $arr, [ 'Foo', 'Bar', ] ); var_dump($result, $result2); function array_map_assoc(callable $callback, array $array, array ...$arrays) { $keys = array_keys($array); array_unshift($arrays, $keys, $array); return array_combine($keys, array_map($callback, ...$arrays)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9XQF9
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $result, !2 = $result2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL_BY_NAME                                       'array_map_assoc'
    5     2        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
    7     3        SEND_VAL_EX                                              ~4
    5     4        SEND_VAR_EX                                              !0
    4     5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   10     7        INIT_FCALL_BY_NAME                                       'array_map_assoc'
   11     8        DECLARE_LAMBDA_FUNCTION                          ~7      [1]
   13     9        SEND_VAL_EX                                              ~7
   11    10        SEND_VAR_EX                                              !0
   16    11        SEND_VAL_EX                                              <array>
   10    12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !2, $8
   20    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   26    18      > 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/9XQF9
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2      > RETURN                                                   !1
    7     3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9XQF9
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $key, !1 = $value, !2 = $value2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   12     3        ROPE_INIT                                     6  ~4      !2
          4        ROPE_ADD                                      1  ~4      ~4, '+%28'
          5        ROPE_ADD                                      2  ~4      ~4, !0
          6        ROPE_ADD                                      3  ~4      ~4, '%3A+'
          7        ROPE_ADD                                      4  ~4      ~4, !1
          8        ROPE_END                                      5  ~3      ~4, '%29'
          9      > RETURN                                                   ~3
   13    10*     > RETURN                                                   null

End of Dynamic Function 1

Function array_map_assoc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9XQF9
function name:  array_map_assoc
number of ops:  23
compiled vars:  !0 = $callback, !1 = $array, !2 = $arrays, !3 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_VARIADIC                                    !2      
   23     3        INIT_FCALL                                               'array_keys'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !3, $4
   24     7        INIT_FCALL                                               'array_unshift'
          8        SEND_REF                                                 !2
          9        SEND_VAR                                                 !3
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   25    12        INIT_FCALL                                               'array_combine'
         13        SEND_VAR                                                 !3
         14        INIT_FCALL                                               'array_map'
         15        SEND_VAR                                                 !0
         16        SEND_UNPACK                                              !2
         17        CHECK_UNDEF_ARGS                                         
         18        DO_ICALL                                         $7      
         19        SEND_VAR                                                 $7
         20        DO_ICALL                                         $8      
         21      > RETURN                                                   $8
   26    22*     > RETURN                                                   null

End of function array_map_assoc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.04 ms | 1007 KiB | 18 Q