3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classType = [ ["class" => "1", "type" => "A"], ["class" => "2", "type" => "A"], ["class" => "3", "type" => "B"] ]; $clollege['studentDetails'] = [ ["grade" => "2", "hobbies" => ["A" , "B"] ], ["grade" => "2", "hobbies" => ["A" ] ], ["grade" => "3", "hobbies" => [ "C" ] ] ]; $classType = array_column($classType, 'type', "class"); array_walk($clollege['studentDetails'], function(&$item) use($classType) { $item['type'] = $classType[$item['grade']]; }); echo '<pre>', print_r($clollege['studentDetails']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BHS4A
function name:  (null)
number of ops:  23
compiled vars:  !0 = $classType, !1 = $clollege
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN_DIM                                               !1, 'studentDetails'
   10     2        OP_DATA                                                  <array>
   15     3        INIT_FCALL                                               'array_column'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'type'
          6        SEND_VAL                                                 'class'
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !0, $4
   16     9        INIT_FCALL                                               'array_walk'
         10        FETCH_DIM_W                                      $6      !1, 'studentDetails'
         11        SEND_REF                                                 $6
         12        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
         13        BIND_LEXICAL                                             ~7, !0
   18    14        SEND_VAL                                                 ~7
   16    15        DO_ICALL                                                 
   20    16        ECHO                                                     '%3Cpre%3E'
         17        INIT_FCALL                                               'print_r'
         18        FETCH_DIM_R                                      ~9      !1, 'studentDetails'
         19        SEND_VAL                                                 ~9
         20        DO_ICALL                                         $10     
         21        ECHO                                                     $10
         22      > 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/BHS4A
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $item, !1 = $classType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   17     2        FETCH_DIM_R                                      ~3      !0, 'grade'
          3        FETCH_DIM_R                                      ~4      !1, ~3
          4        ASSIGN_DIM                                               !0, 'type'
          5        OP_DATA                                                  ~4
   18     6      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.86 ms | 1008 KiB | 16 Q