3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Student { public $studentnummer; public $voornaam; } $apiResult = [ 'firstName' => 'Barry', 'sid' => 'S123', ]; $map = [ 'firstName' => 'voornaam', 'sid' => 'studentnummer', ]; $student = new Student; foreach ($apiResult as $key => $value) { if (isset($map[$key])) { $student->{$map[$key]} = $value; } } print_r($student);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/HrP0O
function name:  (null)
number of ops:  19
compiled vars:  !0 = $apiResult, !1 = $map, !2 = $student, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   19     2        NEW                                              $7      'Student'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   20     5      > FE_RESET_R                                       $10     !0, ->14
          6    > > FE_FETCH_R                                       ~11     $10, !3, ->14
          7    >   ASSIGN                                                   !4, ~11
   21     8        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !4
          9      > JMPZ                                                     ~13, ->13
   22    10    >   FETCH_DIM_R                                      ~14     !1, !4
         11        ASSIGN_OBJ                                               !2, ~14
         12        OP_DATA                                                  !3
   20    13    > > JMP                                                      ->6
         14    >   FE_FREE                                                  $10
   26    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Class Student: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.96 ms | 999 KiB | 14 Q