3v4l.org

run code in 500+ PHP versions simultaneously
<?php $first = array ( 0 => array ( 'id' => 5, 'name' => 'Education' ), 1 => array ( 'id' => 4, 'name' => 'Computers' ), 3 => array ( 'id' => 7, 'name' => 'Science' ), 4 => array ( 'id' => 1, 'name' => 'Sports' ), ); $second = array ( 0 => array ( 'id' => 1, 'title' => 'Sport' ), 1 => array ( 'id' => 7, 'title' => 'Sci' ), 3 => array ( 'id' => 4, 'title' => 'Comp' ), 4 => array ( 'id' => 5, 'title' => 'Edu' ), ); $second = array_column($second, null, 'id'); foreach ($first as &$subject) { $subject = array_merge($subject, $second[$subject['id']] ?? []); } print_r($first);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/9BsEc
function name:  (null)
number of ops:  25
compiled vars:  !0 = $first, !1 = $second, !2 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, <array>
   41     2        INIT_FCALL                                                   'array_column'
          3        SEND_VAR                                                     !1
          4        SEND_VAL                                                     null
          5        SEND_VAL                                                     'id'
          6        DO_ICALL                                             $5      
          7        ASSIGN                                                       !1, $5
   42     8      > FE_RESET_RW                                          $7      !0, ->20
          9    > > FE_FETCH_RW                                                  $7, !2, ->20
   43    10    >   INIT_FCALL                                                   'array_merge'
         11        SEND_VAR                                                     !2
         12        FETCH_DIM_R                                          ~8      !2, 'id'
         13        FETCH_DIM_IS                                         ~9      !1, ~8
         14        COALESCE                                             ~10     ~9
         15        QM_ASSIGN                                            ~10     <array>
         16        SEND_VAL                                                     ~10
         17        DO_ICALL                                             $11     
         18        ASSIGN                                                       !2, $11
   42    19      > JMP                                                          ->9
         20    >   FE_FREE                                                      $7
   45    21        INIT_FCALL                                                   'print_r'
         22        SEND_VAR                                                     !0
         23        DO_ICALL                                                     
         24      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.54 ms | 2210 KiB | 16 Q