3v4l.org

run code in 500+ PHP versions simultaneously
<?php $postcard = 'postcard'; $car = 'car'; $arr_postcard = str_split($postcard); $arr_car = str_split($car); function array_diff_once($array1, $array2) { foreach($array2 as $a) { $pos = array_search($a, $array1); if($pos !== false) { unset($array1[$pos]); } } return $array1; } $uncommon = count($arr_postcard) >= count($arr_car) ? array_diff_once($arr_postcard,$arr_car) : array_diff_once($arr_car,$arr_postcard); echo 'Letters not in common: ' . implode(' - ', $uncommon) . PHP_EOL; function array_intersect_once($array1, $array2) { $array = []; foreach($array1 as $a) { $pos = array_search($a, $array2); if($pos !== false) { $array[] = $a; } } return $array; } $common = count($arr_postcard) >= count($arr_car) ? array_intersect_once($arr_car,$arr_postcard) : array_intersect_once($arr_postcard,$arr_car); echo 'Letters in common: ' . implode(' - ', $common) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
Branch analysis from position: 40
filename:       /in/kK9sE
function name:  (null)
number of ops:  51
compiled vars:  !0 = $postcard, !1 = $car, !2 = $arr_postcard, !3 = $arr_car, !4 = $uncommon, !5 = $common
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'postcard'
    4     1        ASSIGN                                                       !1, 'car'
    6     2        INIT_FCALL                                                   'str_split'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $8      
          5        ASSIGN                                                       !2, $8
    7     6        INIT_FCALL                                                   'str_split'
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                             $10     
          9        ASSIGN                                                       !3, $10
   21    10        COUNT                                                ~12     !2
         11        COUNT                                                ~13     !3
         12        IS_SMALLER_OR_EQUAL                                          ~13, ~12
         13      > JMPZ                                                         ~14, ->20
         14    >   INIT_FCALL                                                   'array_diff_once'
         15        SEND_VAR                                                     !2
         16        SEND_VAR                                                     !3
         17        DO_FCALL                                          0  $15     
         18        QM_ASSIGN                                            ~16     $15
         19      > JMP                                                          ->25
         20    >   INIT_FCALL                                                   'array_diff_once'
         21        SEND_VAR                                                     !3
         22        SEND_VAR                                                     !2
         23        DO_FCALL                                          0  $17     
         24        QM_ASSIGN                                            ~16     $17
         25    >   ASSIGN                                                       !4, ~16
   23    26        FRAMELESS_ICALL_2                implode             ~19     '+-+', !4
         27        CONCAT                                               ~20     'Letters+not+in+common%3A+', ~19
         28        CONCAT                                               ~21     ~20, '%0A'
         29        ECHO                                                         ~21
   36    30        COUNT                                                ~22     !2
         31        COUNT                                                ~23     !3
         32        IS_SMALLER_OR_EQUAL                                          ~23, ~22
         33      > JMPZ                                                         ~24, ->40
         34    >   INIT_FCALL                                                   'array_intersect_once'
         35        SEND_VAR                                                     !3
         36        SEND_VAR                                                     !2
         37        DO_FCALL                                          0  $25     
         38        QM_ASSIGN                                            ~26     $25
         39      > JMP                                                          ->45
         40    >   INIT_FCALL                                                   'array_intersect_once'
         41        SEND_VAR                                                     !2
         42        SEND_VAR                                                     !3
         43        DO_FCALL                                          0  $27     
         44        QM_ASSIGN                                            ~26     $27
         45    >   ASSIGN                                                       !5, ~26
   38    46        FRAMELESS_ICALL_2                implode             ~29     '+-+', !5
         47        CONCAT                                               ~30     'Letters+in+common%3A+', ~29
         48        CONCAT                                               ~31     ~30, '%0A'
         49        ECHO                                                         ~31
   39    50      > RETURN                                                       1

Function array_diff_once:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/kK9sE
function name:  array_diff_once
number of ops:  16
compiled vars:  !0 = $array1, !1 = $array2, !2 = $a, !3 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   11     2      > FE_RESET_R                                           $4      !1, ->13
          3    > > FE_FETCH_R                                                   $4, !2, ->13
   12     4    >   INIT_FCALL                                                   'array_search'
          5        SEND_VAR                                                     !2
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                             $5      
          8        ASSIGN                                                       !3, $5
   13     9        TYPE_CHECK                                      1018          !3
         10      > JMPZ                                                         ~7, ->12
   14    11    >   UNSET_DIM                                                    !0, !3
   11    12    > > JMP                                                          ->3
         13    >   FE_FREE                                                      $4
   18    14      > RETURN                                                       !0
   19    15*     > RETURN                                                       null

End of function array_diff_once

Function array_intersect_once:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
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/kK9sE
function name:  array_intersect_once
number of ops:  18
compiled vars:  !0 = $array1, !1 = $array2, !2 = $array, !3 = $a, !4 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   26     2        ASSIGN                                                       !2, <array>
   27     3      > FE_RESET_R                                           $6      !0, ->15
          4    > > FE_FETCH_R                                                   $6, !3, ->15
   28     5    >   INIT_FCALL                                                   'array_search'
          6        SEND_VAR                                                     !3
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                             $7      
          9        ASSIGN                                                       !4, $7
   29    10        TYPE_CHECK                                      1018          !4
         11      > JMPZ                                                         ~9, ->14
   30    12    >   ASSIGN_DIM                                                   !2
         13        OP_DATA                                                      !3
   27    14    > > JMP                                                          ->4
         15    >   FE_FREE                                                      $6
   34    16      > RETURN                                                       !2
   35    17*     > RETURN                                                       null

End of function array_intersect_once

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.42 ms | 1992 KiB | 19 Q