3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "car apple computer car"; $string2 = "car apple computer"; function hasSameWords($string) { $array = explode(' ', $string); $count = count($array); $unique = array_unique($array); $uniqueCount = count($unique); return $uniqueCount < $count; } echo hasSameWords($string) ? 'true' : 'false'; echo hasSameWords($string2) ? 'true' : 'false';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
Branch analysis from position: 16
filename:       /in/8iidN
function name:  (null)
number of ops:  19
compiled vars:  !0 = $string, !1 = $string2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'car+apple+computer+car'
    4     1        ASSIGN                                                   !1, 'car+apple+computer'
   14     2        INIT_FCALL                                               'hassamewords'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $4      
          5      > JMPZ                                                     $4, ->8
          6    >   QM_ASSIGN                                        ~5      'true'
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      'false'
          9    >   ECHO                                                     ~5
   15    10        INIT_FCALL                                               'hassamewords'
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $6      
         13      > JMPZ                                                     $6, ->16
         14    >   QM_ASSIGN                                        ~7      'true'
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~7      'false'
         17    >   ECHO                                                     ~7
         18      > RETURN                                                   1

Function hassamewords:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8iidN
function name:  hasSameWords
number of ops:  17
compiled vars:  !0 = $string, !1 = $array, !2 = $count, !3 = $unique, !4 = $uniqueCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    8     6        COUNT                                            ~7      !1
          7        ASSIGN                                                   !2, ~7
    9     8        INIT_FCALL                                               'array_unique'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !3, $9
   10    12        COUNT                                            ~11     !3
         13        ASSIGN                                                   !4, ~11
   11    14        IS_SMALLER                                       ~13     !4, !2
         15      > RETURN                                                   ~13
   12    16*     > RETURN                                                   null

End of function hassamewords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.53 ms | 1019 KiB | 17 Q