3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "this is my my word with new word"; //echo count(str_word_count($string)); echo unique_word_count($string); function unique_word_count($string) { //$string = explode(' ', strtolower($string)); //$string = str_word_count($string, 1); $string = preg_split('\s', strtolower($string)); $words = array_unique($string); return count($words); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IY8Bc
function name:  (null)
number of ops:  6
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'this+is+my+my+word+with+new+word'
    6     1        INIT_FCALL_BY_NAME                                       'unique_word_count'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   14     5      > RETURN                                                   1

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

End of function unique_word_count

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.88 ms | 1395 KiB | 19 Q