3v4l.org

run code in 300+ PHP versions simultaneously
<?php function 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 && $title[$i] !== '\'' && 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 slugify('This is not a love song').PHP_EOL; echo slugify('There\'s a lady who is sure').PHP_EOL; echo slugify('All that is gold does not glitter ').PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vHrcO
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'slugify'
          1        SEND_VAL                                                 'This+is+not+a+love+song'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   27     5        INIT_FCALL                                               'slugify'
          6        SEND_VAL                                                 'There%27s+a+lady+who+is+sure'
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%0A'
          9        ECHO                                                     ~3
   28    10        INIT_FCALL                                               'slugify'
         11        SEND_VAL                                                 'All+that+is+gold+does+++not+glitter++'
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '%0A'
         14        ECHO                                                     ~5
         15      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 7
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
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 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 7
Branch analysis from position: 39
Branch analysis from position: 7
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 7
Branch analysis from position: 39
Branch analysis from position: 7
Branch analysis from position: 36
Branch analysis from position: 34
Branch analysis from position: 25
filename:       /in/vHrcO
function name:  slugify
number of ops:  55
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                                                      ->37
    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                                                      ->36
   12    20    >   IS_SMALLER                                       ~16     0, !4
         21      > JMPZ_EX                                          ~16     ~16, ->25
         22    >   FETCH_DIM_R                                      ~17     !0, !4
         23        IS_NOT_IDENTICAL                                 ~18     ~17, '%27'
         24        BOOL                                             ~16     ~18
         25    > > JMPZ_EX                                          ~16     ~16, ->34
         26    >   INIT_FCALL                                               'stripos'
         27        SEND_VAR                                                 !2
         28        SUB                                              ~19     !4, 1
         29        FETCH_DIM_R                                      ~20     !0, ~19
         30        SEND_VAL                                                 ~20
         31        DO_ICALL                                         $21     
         32        TYPE_CHECK                                  1018  ~22     $21
         33        BOOL                                             ~16     ~22
         34    > > JMPZ                                                     ~16, ->36
   15    35    >   ASSIGN_OP                                     8          !1, '-'
    8    36    >   PRE_INC                                                  !4
         37    >   IS_SMALLER                                               !4, !3
         38      > JMPNZ                                                    ~25, ->7
   19    39    >   INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !1
         41        SEND_VAL                                                 -1
         42        SEND_VAL                                                 1
         43        DO_ICALL                                         $26     
         44        IS_IDENTICAL                                             $26, '-'
         45      > JMPZ                                                     ~27, ->53
   20    46    >   INIT_FCALL                                               'substr'
         47        SEND_VAR                                                 !1
         48        SEND_VAL                                                 0
         49        SEND_VAL                                                 -1
         50        DO_ICALL                                         $28     
         51      > RETURN                                                   $28
         52*       JMP                                                      ->54
   22    53    > > RETURN                                                   !1
   24    54*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.7 ms | 1402 KiB | 22 Q