3v4l.org

run code in 300+ PHP versions simultaneously
<?php function op_slugify($title) { $output = ''; $valid_characters = 'abcdefghijklmnopqrstuvwxyz1234567890'; $len = strlen($title); for ($i = 0;$i < $len;$i++) { if (stripos($valid_characters, $title[$i]) !== FALSE) { // Letters and numbers are valid $output .= strtolower($title[$i]); } elseif ($i > 0 && stripos($valid_characters, $title[$i - 1]) !== FALSE) { // Other characters are turned into dashes, but never two // in a row. $output .= '-'; } } if (substr($output, -1, 1) === '-') { return substr($output, 0, -1); } else { return $output; } } echo op_slugify('The Old, North State!!');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PeRaO
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'op_slugify'
          1        SEND_VAL                                                 'The+Old%2C+North+State%21%21'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function op_slugify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 7
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 7
Branch analysis from position: 35
Branch analysis from position: 7
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 7
Branch analysis from position: 35
Branch analysis from position: 7
Branch analysis from position: 32
Branch analysis from position: 30
filename:       /in/PeRaO
function name:  op_slugify
number of ops:  51
compiled vars:  !0 = $title, !1 = $output, !2 = $valid_characters, !3 = $len, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    5     2        ASSIGN                                                   !2, 'abcdefghijklmnopqrstuvwxyz1234567890'
    7     3        STRLEN                                           ~7      !0
          4        ASSIGN                                                   !3, ~7
    8     5        ASSIGN                                                   !4, 0
          6      > JMP                                                      ->33
    9     7    >   INIT_FCALL                                               'stripos'
          8        SEND_VAR                                                 !2
          9        FETCH_DIM_R                                      ~10     !0, !4
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        TYPE_CHECK                                  1018          $11
         13      > JMPZ                                                     ~12, ->20
   11    14    >   INIT_FCALL                                               'strtolower'
         15        FETCH_DIM_R                                      ~13     !0, !4
         16        SEND_VAL                                                 ~13
         17        DO_ICALL                                         $14     
         18        ASSIGN_OP                                     8          !1, $14
         19      > JMP                                                      ->32
   12    20    >   IS_SMALLER                                       ~16     0, !4
         21      > JMPZ_EX                                          ~16     ~16, ->30
         22    >   INIT_FCALL                                               'stripos'
         23        SEND_VAR                                                 !2
         24        SUB                                              ~17     !4, 1
         25        FETCH_DIM_R                                      ~18     !0, ~17
         26        SEND_VAL                                                 ~18
         27        DO_ICALL                                         $19     
         28        TYPE_CHECK                                  1018  ~20     $19
         29        BOOL                                             ~16     ~20
         30    > > JMPZ                                                     ~16, ->32
   15    31    >   ASSIGN_OP                                     8          !1, '-'
    8    32    >   PRE_INC                                                  !4
         33    >   IS_SMALLER                                               !4, !3
         34      > JMPNZ                                                    ~23, ->7
   19    35    >   INIT_FCALL                                               'substr'
         36        SEND_VAR                                                 !1
         37        SEND_VAL                                                 -1
         38        SEND_VAL                                                 1
         39        DO_ICALL                                         $24     
         40        IS_IDENTICAL                                             $24, '-'
         41      > JMPZ                                                     ~25, ->49
   20    42    >   INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !1
         44        SEND_VAL                                                 0
         45        SEND_VAL                                                 -1
         46        DO_ICALL                                         $26     
         47      > RETURN                                                   $26
         48*       JMP                                                      ->50
   22    49    > > RETURN                                                   !1
   24    50*     > RETURN                                                   null

End of function op_slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.07 ms | 1403 KiB | 20 Q