3v4l.org

run code in 300+ PHP versions simultaneously
<?php $students = Array( Array( 'userId' => 'user1', 'name' => 'Suman Mandal', 'age' => 20, ), Array( 'userId' => 'user2', 'name' => 'Amit Halder', 'age' => 30, ), Array( 'userId' => 'user3', 'name' => 'Asif Rahman', 'age' => 25, ), Array( 'userId' => 'user4', 'name' => 'Gopal Ghosh', 'age' => 21, ) ); $marks = Array( Array( 'userId' => 'user1', 'marks'=>80, ), Array( 'userId' => 'user3', 'marks'=>90, ) ); $marks_sheet = []; foreach ($marks as $mark) { foreach ($students as $student) { if ($student['userId'] === $mark['userId']) { $mark_sheet = $student; foreach ($mark as $key => $value) { $mark_sheet[$key] = $value; } $marks_sheet[] = $mark_sheet; } } } print_r($marks_sheet);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 22
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 18
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/Xmg3a
function name:  (null)
number of ops:  29
compiled vars:  !0 = $students, !1 = $marks, !2 = $marks_sheet, !3 = $mark, !4 = $student, !5 = $mark_sheet, !6 = $value, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, <array>
   40     2        ASSIGN                                                   !2, <array>
   41     3      > FE_RESET_R                                       $11     !1, ->24
          4    > > FE_FETCH_R                                               $11, !3, ->24
   42     5    > > FE_RESET_R                                       $12     !0, ->22
          6    > > FE_FETCH_R                                               $12, !4, ->22
   43     7    >   FETCH_DIM_R                                      ~13     !4, 'userId'
          8        FETCH_DIM_R                                      ~14     !3, 'userId'
          9        IS_IDENTICAL                                             ~13, ~14
         10      > JMPZ                                                     ~15, ->21
   44    11    >   ASSIGN                                                   !5, !4
   45    12      > FE_RESET_R                                       $17     !3, ->18
         13    > > FE_FETCH_R                                       ~18     $17, !6, ->18
         14    >   ASSIGN                                                   !7, ~18
   46    15        ASSIGN_DIM                                               !5, !7
         16        OP_DATA                                                  !6
   45    17      > JMP                                                      ->13
         18    >   FE_FREE                                                  $17
   48    19        ASSIGN_DIM                                               !2
         20        OP_DATA                                                  !5
   42    21    > > JMP                                                      ->6
         22    >   FE_FREE                                                  $12
   41    23      > JMP                                                      ->4
         24    >   FE_FREE                                                  $11
   53    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.04 ms | 1011 KiB | 14 Q