3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "mozzzaaaaaarelaaaaaa"; $string = preg_replace('/^-+/','',$string); echo $string; function setString($phrase, $length = null) { $result = strtolower($phrase); $result = trim(preg_replace("/[^0-9a-zA-Z-]/", "-", $result)); $result = preg_replace("/--+/", "-", $result); $result = !empty($length) ? substr($result, 0, $length) : $result; // remove hyphen from the beginning (if exists) $first_char = substr($result, 0, 1); $result = $first_char == "-" ? substr($result, 1) : $result; // remove hyphen from the end (if exists) $last_char = substr($result, -1); $result = $last_char == "-" ? substr($result, 0, -1) : $result; return $result; } echo setString($string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kb0iU
function name:  (null)
number of ops:  13
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'mozzzaaaaaarelaaaaaa'
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5E-%2B%2F'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
    6     7        ECHO                                                     !0
   22     8        INIT_FCALL                                               'setstring'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $4      
         11        ECHO                                                     $4
         12      > RETURN                                                   1

Function setstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 63
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 63
Branch analysis from position: 56
Branch analysis from position: 63
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
Branch analysis from position: 47
filename:       /in/Kb0iU
function name:  setString
number of ops:  67
compiled vars:  !0 = $phrase, !1 = $length, !2 = $result, !3 = $first_char, !4 = $last_char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    9     2        INIT_FCALL                                               'strtolower'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   10     6        INIT_FCALL                                               'trim'
          7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%5B%5E0-9a-zA-Z-%5D%2F'
          9        SEND_VAL                                                 '-'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   11    15        INIT_FCALL                                               'preg_replace'
         16        SEND_VAL                                                 '%2F--%2B%2F'
         17        SEND_VAL                                                 '-'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $10     
         20        ASSIGN                                                   !2, $10
   12    21        ISSET_ISEMPTY_CV                                 ~12     !1
         22        BOOL_NOT                                         ~13     ~12
         23      > JMPZ                                                     ~13, ->31
         24    >   INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !2
         26        SEND_VAL                                                 0
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $14     
         29        QM_ASSIGN                                        ~15     $14
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~15     !2
         32    >   ASSIGN                                                   !2, ~15
   14    33        INIT_FCALL                                               'substr'
         34        SEND_VAR                                                 !2
         35        SEND_VAL                                                 0
         36        SEND_VAL                                                 1
         37        DO_ICALL                                         $17     
         38        ASSIGN                                                   !3, $17
   15    39        IS_EQUAL                                                 !3, '-'
         40      > JMPZ                                                     ~19, ->47
         41    >   INIT_FCALL                                               'substr'
         42        SEND_VAR                                                 !2
         43        SEND_VAL                                                 1
         44        DO_ICALL                                         $20     
         45        QM_ASSIGN                                        ~21     $20
         46      > JMP                                                      ->48
         47    >   QM_ASSIGN                                        ~21     !2
         48    >   ASSIGN                                                   !2, ~21
   17    49        INIT_FCALL                                               'substr'
         50        SEND_VAR                                                 !2
         51        SEND_VAL                                                 -1
         52        DO_ICALL                                         $23     
         53        ASSIGN                                                   !4, $23
   18    54        IS_EQUAL                                                 !4, '-'
         55      > JMPZ                                                     ~25, ->63
         56    >   INIT_FCALL                                               'substr'
         57        SEND_VAR                                                 !2
         58        SEND_VAL                                                 0
         59        SEND_VAL                                                 -1
         60        DO_ICALL                                         $26     
         61        QM_ASSIGN                                        ~27     $26
         62      > JMP                                                      ->64
         63    >   QM_ASSIGN                                        ~27     !2
         64    >   ASSIGN                                                   !2, ~27
   19    65      > RETURN                                                   !2
   20    66*     > RETURN                                                   null

End of function setstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.41 ms | 1407 KiB | 22 Q