3v4l.org

run code in 300+ PHP versions simultaneously
<?php function my_array_diff($a, $b) { $map = $out = array(); foreach($a as $val) $map[$val] = 1; foreach($b as $val) if(isset($map[$val])) $map[$val] = 0; foreach($map as $val => $ok) if($ok) $out[] = $val; return $out; } $a=array('a','A','b'); $b=array('A','c','b'); $t1=time(); print_r(my_array_diff($a,$b)); $t2=time()-$t1; echo $t2; $t1=time(); print_r(array_diff($a,$b)); $t2=time()-$t1; echo $t2;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YHj4p
function name:  (null)
number of ops:  33
compiled vars:  !0 = $a, !1 = $b, !2 = $t1, !3 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2        INIT_FCALL                                               'time'
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !2, $6
   13     5        INIT_FCALL                                               'print_r'
          6        INIT_FCALL                                               'my_array_diff'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $8      
         10        SEND_VAR                                                 $8
         11        DO_ICALL                                                 
   14    12        INIT_FCALL                                               'time'
         13        DO_ICALL                                         $10     
         14        SUB                                              ~11     $10, !2
         15        ASSIGN                                                   !3, ~11
   15    16        ECHO                                                     !3
   16    17        INIT_FCALL                                               'time'
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !2, $13
   17    20        INIT_FCALL                                               'print_r'
         21        INIT_FCALL                                               'array_diff'
         22        SEND_VAR                                                 !0
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $15     
         25        SEND_VAR                                                 $15
         26        DO_ICALL                                                 
   18    27        INIT_FCALL                                               'time'
         28        DO_ICALL                                         $17     
         29        SUB                                              ~18     $17, !2
         30        ASSIGN                                                   !3, ~18
   19    31        ECHO                                                     !3
         32      > RETURN                                                   1

Function my_array_diff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 17
Branch analysis from position: 9
filename:       /in/YHj4p
function name:  my_array_diff
number of ops:  28
compiled vars:  !0 = $a, !1 = $b, !2 = $map, !3 = $out, !4 = $val, !5 = $ok
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                           ~6      !3, <array>
          3        ASSIGN                                                   !2, ~6
    4     4      > FE_RESET_R                                       $8      !0, ->9
          5    > > FE_FETCH_R                                               $8, !4, ->9
          6    >   ASSIGN_DIM                                               !2, !4
          7        OP_DATA                                                  1
          8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $8
    5    10      > FE_RESET_R                                       $10     !1, ->17
         11    > > FE_FETCH_R                                               $10, !4, ->17
         12    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
         13      > JMPZ                                                     ~11, ->16
         14    >   ASSIGN_DIM                                               !2, !4
         15        OP_DATA                                                  0
         16    > > JMP                                                      ->11
         17    >   FE_FREE                                                  $10
    6    18      > FE_RESET_R                                       $13     !2, ->25
         19    > > FE_FETCH_R                                       ~14     $13, !5, ->25
         20    >   ASSIGN                                                   !4, ~14
         21      > JMPZ                                                     !5, ->24
         22    >   ASSIGN_DIM                                               !3
         23        OP_DATA                                                  !4
         24    > > JMP                                                      ->19
         25    >   FE_FREE                                                  $13
    7    26      > RETURN                                                   !3
    8    27*     > RETURN                                                   null

End of function my_array_diff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.56 ms | 1403 KiB | 20 Q