3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 1234455; $b = 54456; function digits_in_both($x, $y) { $in_both = []; $split_y = str_split($y); foreach(str_split($x) as $n) { $key = array_search($n, $split_y); if($key !== false) { $in_both[] = $n; unset($split_y[$key]); } } return $in_both; } $in_both = digits_in_both(123445, 54456); var_export($in_both); var_dump(count($in_both));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y60bn
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a, !1 = $b, !2 = $in_both
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1234455
    4     1        ASSIGN                                                   !1, 54456
   20     2        INIT_FCALL                                               'digits_in_both'
          3        SEND_VAL                                                 123445
          4        SEND_VAL                                                 54456
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   21     7        INIT_FCALL                                               'var_export'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   22    10        INIT_FCALL                                               'var_dump'
         11        COUNT                                            ~8      !2
         12        SEND_VAL                                                 ~8
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function digits_in_both:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Y60bn
function name:  digits_in_both
number of ops:  26
compiled vars:  !0 = $x, !1 = $y, !2 = $in_both, !3 = $split_y, !4 = $n, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, <array>
    8     3        INIT_FCALL                                               'str_split'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !3, $7
    9     7        INIT_FCALL                                               'str_split'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $9      
         10      > FE_RESET_R                                       $10     $9, ->23
         11    > > FE_FETCH_R                                               $10, !4, ->23
   10    12    >   INIT_FCALL                                               'array_search'
         13        SEND_VAR                                                 !4
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !5, $11
   11    17        TYPE_CHECK                                  1018          !5
         18      > JMPZ                                                     ~13, ->22
   12    19    >   ASSIGN_DIM                                               !2
         20        OP_DATA                                                  !4
   13    21        UNSET_DIM                                                !3, !5
    9    22    > > JMP                                                      ->11
         23    >   FE_FREE                                                  $10
   17    24      > RETURN                                                   !2
   18    25*     > RETURN                                                   null

End of function digits_in_both

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.79 ms | 1402 KiB | 22 Q