3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_1 = array( 'apple'=>1,'banana'=>2,'coconut'=> 3); $array_2 = array( 'apple'=>2,'banana'=>3,'coconut'=> 4); foreach( $array_1 as $fruit => $num) { if(array_key_exists($fruit, $array_2)){ //check if key from array_1 exists in array_2 $final_array[] = array($fruit => $array_1[$fruit].','.$array_2[$fruit]); //concatenate values from shared key } } print_r (final_array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/Uiam0
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array_1, !1 = $array_2, !2 = $num, !3 = $fruit, !4 = $final_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $7      !0, ->15
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->15
          4    >   ASSIGN                                                   !3, ~8
    7     5        ARRAY_KEY_EXISTS                                         !3, !1
          6      > JMPZ                                                     ~10, ->14
    8     7    >   FETCH_DIM_R                                      ~12     !0, !3
          8        CONCAT                                           ~13     ~12, '%2C'
          9        FETCH_DIM_R                                      ~14     !1, !3
         10        CONCAT                                           ~15     ~13, ~14
         11        INIT_ARRAY                                       ~16     ~15, !3
         12        ASSIGN_DIM                                               !4
         13        OP_DATA                                                  ~16
    6    14    > > JMP                                                      ->3
         15    >   FE_FREE                                                  $7
   11    16        INIT_FCALL                                               'print_r'
         17        FETCH_CONSTANT                                   ~17     'final_array'
         18        SEND_VAL                                                 ~17
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.07 ms | 1395 KiB | 15 Q