3v4l.org

run code in 300+ PHP versions simultaneously
<?php $students = [ [ 'id' => '498', 'uuid' => '6cb91efd-9111-4be8-a2d7-80d3edeed732', 'name' => 'Andrew A. Blaine', 'email' => 'student14@gmail1.com', 'usertype_id' => '6', 'first_name' => 'Andrew A.', 'last_name' => 'Blaine', ], [ 'id' => '499', 'uuid' => '208764a0-c53d-404b-ad05-ee7cba28a51c', 'name' => 'Billie C. Heath', 'email' => 'student15@gmail1.com', 'usertype_id' => '6', 'first_name' => 'Billie C.', 'last_name' => 'Heath', ] ]; $fields = ['id', 'name', 'email']; $newStudents = array_map(function ($student) use ($fields) { $newS = []; foreach ($fields as $field) { if (array_key_exists($field, $student)) { $newS[$field] = $student[$field]; } } return $newS; }, $students); print_r($newStudents);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AXiFL
function name:  (null)
number of ops:  13
compiled vars:  !0 = $students, !1 = $fields, !2 = $newStudents
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, <array>
   26     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        BIND_LEXICAL                                             ~5, !1
   34     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !0
   26     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   36     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
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
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/AXiFL
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $student, !1 = $fields, !2 = $newS, !3 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   27     2        ASSIGN                                                   !2, <array>
   28     3      > FE_RESET_R                                       $5      !1, ->11
          4    > > FE_FETCH_R                                               $5, !3, ->11
   29     5    >   ARRAY_KEY_EXISTS                                         !3, !0
          6      > JMPZ                                                     ~6, ->10
   30     7    >   FETCH_DIM_R                                      ~8      !0, !3
          8        ASSIGN_DIM                                               !2, !3
          9        OP_DATA                                                  ~8
   28    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $5
   33    12      > RETURN                                                   !2
   34    13*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.68 ms | 1012 KiB | 15 Q