3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arraySession = [ 'sampleA' => ['1', '2', '3'], 'sampleB' => ['1', '2', '3'], ]; $arrayPost = [ 'sampleA' => ['1'], 'sampleB' => ['1','2'], ]; var_export( array_reduce( array_keys($arraySession), fn($result, $k) => $result + [$k => array_diff($arraySession[$k], $arrayPost[$k] ?? [])], [] ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M9SkN
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arraySession, !1 = $arrayPost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'var_export'
   14     3        INIT_FCALL                                               'array_reduce'
   15     4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
   16     8        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          9        BIND_LEXICAL                                             ~5, !0
         10        BIND_LEXICAL                                             ~5, !1
         11        SEND_VAL                                                 ~5
   17    12        SEND_VAL                                                 <array>
   14    13        DO_ICALL                                         $6      
   17    14        SEND_VAR                                                 $6
   13    15        DO_ICALL                                                 
   19    16      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M9SkN
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $result, !1 = $k, !2 = $arraySession, !3 = $arrayPost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        INIT_FCALL                                               'array_diff'
          5        FETCH_DIM_R                                      ~4      !2, !1
          6        SEND_VAL                                                 ~4
          7        FETCH_DIM_IS                                     ~5      !3, !1
          8        COALESCE                                         ~6      ~5
          9        QM_ASSIGN                                        ~6      <array>
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                         $7      
         12        INIT_ARRAY                                       ~8      $7, !1
         13        ADD                                              ~9      !0, ~8
         14      > RETURN                                                   ~9
         15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.83 ms | 1014 KiB | 17 Q