3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "pentrose_50_rafhan_c_kgs" => 100, "pentrose_50_rafhan_c_issued_kgs" => 300, "pentrose_50_rafhan_c_rskg" => 99.1, "pentrose_50_rafhan_c_amount" => 29730, ]; $formattedArray = []; array_walk($array, function($value, $key) use (&$formattedArray) { list($prefix, $newKey) = explode('_c_', $key); $formattedArray[$prefix][$newKey] = $value; }); var_dump($formattedArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jPHB8
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $formattedArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   12     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   15     6        SEND_VAL                                                 ~4
   12     7        DO_ICALL                                                 
   17     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > 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/jPHB8
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $value, !1 = $key, !2 = $formattedArray, !3 = $prefix, !4 = $newKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   13     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '_c_'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        FETCH_LIST_R                                     $6      $5, 0
          8        ASSIGN                                                   !3, $6
          9        FETCH_LIST_R                                     $8      $5, 1
         10        ASSIGN                                                   !4, $8
         11        FREE                                                     $5
   14    12        FETCH_DIM_W                                      $10     !2, !3
         13        ASSIGN_DIM                                               $10, !4
         14        OP_DATA                                                  !0
   15    15      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.91 ms | 1005 KiB | 16 Q