3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Samsung UN32EH4003 32-inch 720p 60Hz LED HDTV (Black)'; echo shorten_string($string); function shorten_string($string,$count=5){ $arr = preg_split('/[,\ \.;]/', $string); $keywords = array_unique($arr); $i=0; $rtn = ''; foreach ($keywords as $keyword){ if ((preg_match("/^[a-z0-9]/i", $keyword) ) && (strlen($keyword) > 3)){ $rtn .= $keyword.' '; $i++; if ($i==$count) break; } } return trim($rtn); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McfKK
function name:  (null)
number of ops:  6
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Samsung+UN32EH4003+32-inch+720p+60Hz+LED+HDTV+%28Black%29'
    3     1        INIT_FCALL_BY_NAME                                       'shorten_string'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   18     5      > RETURN                                                   1

Function shorten_string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 31
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
Branch analysis from position: 23
Branch analysis from position: 31
Branch analysis from position: 31
filename:       /in/McfKK
function name:  shorten_string
number of ops:  37
compiled vars:  !0 = $string, !1 = $count, !2 = $arr, !3 = $keywords, !4 = $i, !5 = $rtn, !6 = $keyword
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      5
    6     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%2F%5B%2C%5C+%5C.%3B%5D%2F'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !2, $7
    7     7        INIT_FCALL                                               'array_unique'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !3, $9
    8    11        ASSIGN                                                   !4, 0
    9    12        ASSIGN                                                   !5, ''
   10    13      > FE_RESET_R                                       $13     !3, ->31
         14    > > FE_FETCH_R                                               $13, !6, ->31
   11    15    >   INIT_FCALL                                               'preg_match'
         16        SEND_VAL                                                 '%2F%5E%5Ba-z0-9%5D%2Fi'
         17        SEND_VAR                                                 !6
         18        DO_ICALL                                         $14     
         19      > JMPZ_EX                                          ~15     $14, ->23
         20    >   STRLEN                                           ~16     !6
         21        IS_SMALLER                                       ~17     3, ~16
         22        BOOL                                             ~15     ~17
         23    > > JMPZ                                                     ~15, ->30
   12    24    >   CONCAT                                           ~18     !6, '+'
         25        ASSIGN_OP                                     8          !5, ~18
   13    26        PRE_INC                                                  !4
   14    27        IS_EQUAL                                                 !4, !1
         28      > JMPZ                                                     ~21, ->30
         29    > > JMP                                                      ->31
   10    30    > > JMP                                                      ->14
         31    >   FE_FREE                                                  $13
   17    32        INIT_FCALL                                               'trim'
         33        SEND_VAR                                                 !5
         34        DO_ICALL                                         $22     
         35      > RETURN                                                   $22
   18    36*     > RETURN                                                   null

End of function shorten_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.3 ms | 1400 KiB | 21 Q