3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remapInternationalCharToAscii($c) { return $c; } function sluggify($title) { if ($title === null) return ""; $maxlen = 80; $len = strlen($title); $prevdash = false; $slug = ""; for ($i = 0; $i < $len; $i++) { $c = $title[$i]; if (($c >= 'a' && $c <= 'z') || ($c >= '0' && $c <= '9')) { $slug .= $c; $prevdash = false; } else if ($c >= 'A' && $c <= 'Z') { echo 'hi!'; $slug .= strtolower($c); $prevdash = false; } else if ($c == ' ' || $c == ',' || $c == '.' || $c == '/' || $c == '\\' || $c == '-' || $c == '_' || $c == '=') { if (!$prevdash && strlen($slug) > 0) { $slug .= '-'; $prevdash = true; } } else if ((int) $c >= 128) { $prevlen = strlen($slug); $slug .= remapInternationalCharToAscii($c); if ($prevlen != strlen($slug)) $prevdash = false; } if ($i == $maxlen) break; } if ($prevdash) { return substr($slug, 0, strlen($slug) - 1); } return $slug; } echo sluggify('Hello World');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHJXi
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   INIT_FCALL                                               'sluggify'
          1        SEND_VAL                                                 'Hello+World'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function remapinternationalchartoascii:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHJXi
function name:  remapInternationalCharToAscii
number of ops:  3
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1      > RETURN                                                   !0
    6     2*     > RETURN                                                   null

End of function remapinternationalchartoascii

Function sluggify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 88
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 90, Position 2 = 11
Branch analysis from position: 90
2 jumps found. (Code = 43) Position 1 = 91, Position 2 = 99
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 99
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 87
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
Branch analysis from position: 87
2 jumps found. (Code = 44) Position 1 = 90, Position 2 = 11
Branch analysis from position: 90
Branch analysis from position: 11
Branch analysis from position: 27
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Branch analysis from position: 39
2 jumps found. (Code = 47) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
2 jumps found. (Code = 47) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 47) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
2 jumps found. (Code = 47) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
2 jumps found. (Code = 47) Position 1 = 53, Position 2 = 55
Branch analysis from position: 53
2 jumps found. (Code = 47) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
2 jumps found. (Code = 47) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 71
Branch analysis from position: 62
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 70
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Branch analysis from position: 70
Branch analysis from position: 67
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 84
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 84
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 87
Branch analysis from position: 86
Branch analysis from position: 87
Branch analysis from position: 84
Branch analysis from position: 84
Branch analysis from position: 61
Branch analysis from position: 58
Branch analysis from position: 55
Branch analysis from position: 52
Branch analysis from position: 49
Branch analysis from position: 46
Branch analysis from position: 43
Branch analysis from position: 31
Branch analysis from position: 22
Branch analysis from position: 23
Branch analysis from position: 17
filename:       /in/bHJXi
function name:  sluggify
number of ops:  101
compiled vars:  !0 = $title, !1 = $maxlen, !2 = $len, !3 = $prevdash, !4 = $slug, !5 = $i, !6 = $c, !7 = $prevlen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~8, ->4
          3    > > RETURN                                                   ''
   12     4    >   ASSIGN                                                   !1, 80
   13     5        STRLEN                                           ~10     !0
          6        ASSIGN                                                   !2, ~10
   14     7        ASSIGN                                                   !3, <false>
   15     8        ASSIGN                                                   !4, ''
   17     9        ASSIGN                                                   !5, 0
         10      > JMP                                                      ->88
   19    11    >   FETCH_DIM_R                                      ~15     !0, !5
         12        ASSIGN                                                   !6, ~15
   21    13        IS_SMALLER_OR_EQUAL                              ~17     'a', !6
         14      > JMPZ_EX                                          ~17     ~17, ->17
         15    >   IS_SMALLER_OR_EQUAL                              ~18     !6, 'z'
         16        BOOL                                             ~17     ~18
         17    > > JMPNZ_EX                                         ~17     ~17, ->23
         18    >   IS_SMALLER_OR_EQUAL                              ~19     '0', !6
         19      > JMPZ_EX                                          ~19     ~19, ->22
         20    >   IS_SMALLER_OR_EQUAL                              ~20     !6, '9'
         21        BOOL                                             ~19     ~20
         22    >   BOOL                                             ~17     ~19
         23    > > JMPZ                                                     ~17, ->27
   22    24    >   ASSIGN_OP                                     8          !4, !6
   23    25        ASSIGN                                                   !3, <false>
         26      > JMP                                                      ->84
   25    27    >   IS_SMALLER_OR_EQUAL                              ~23     'A', !6
         28      > JMPZ_EX                                          ~23     ~23, ->31
         29    >   IS_SMALLER_OR_EQUAL                              ~24     !6, 'Z'
         30        BOOL                                             ~23     ~24
         31    > > JMPZ                                                     ~23, ->39
   27    32    >   ECHO                                                     'hi%21'
   28    33        INIT_FCALL                                               'strtolower'
         34        SEND_VAR                                                 !6
         35        DO_ICALL                                         $25     
         36        ASSIGN_OP                                     8          !4, $25
   29    37        ASSIGN                                                   !3, <false>
         38      > JMP                                                      ->84
   31    39    >   IS_EQUAL                                         ~28     !6, '+'
         40      > JMPNZ_EX                                         ~28     ~28, ->43
         41    >   IS_EQUAL                                         ~29     !6, '%2C'
         42        BOOL                                             ~28     ~29
         43    > > JMPNZ_EX                                         ~28     ~28, ->46
         44    >   IS_EQUAL                                         ~30     !6, '.'
         45        BOOL                                             ~28     ~30
         46    > > JMPNZ_EX                                         ~28     ~28, ->49
         47    >   IS_EQUAL                                         ~31     !6, '%2F'
         48        BOOL                                             ~28     ~31
         49    > > JMPNZ_EX                                         ~28     ~28, ->52
   32    50    >   IS_EQUAL                                         ~32     !6, '%5C'
         51        BOOL                                             ~28     ~32
         52    > > JMPNZ_EX                                         ~28     ~28, ->55
         53    >   IS_EQUAL                                         ~33     !6, '-'
         54        BOOL                                             ~28     ~33
         55    > > JMPNZ_EX                                         ~28     ~28, ->58
         56    >   IS_EQUAL                                         ~34     !6, '_'
         57        BOOL                                             ~28     ~34
         58    > > JMPNZ_EX                                         ~28     ~28, ->61
         59    >   IS_EQUAL                                         ~35     !6, '%3D'
         60        BOOL                                             ~28     ~35
         61    > > JMPZ                                                     ~28, ->71
   34    62    >   BOOL_NOT                                         ~36     !3
         63      > JMPZ_EX                                          ~36     ~36, ->67
         64    >   STRLEN                                           ~37     !4
         65        IS_SMALLER                                       ~38     0, ~37
         66        BOOL                                             ~36     ~38
         67    > > JMPZ                                                     ~36, ->70
   36    68    >   ASSIGN_OP                                     8          !4, '-'
   37    69        ASSIGN                                                   !3, <true>
         70    > > JMP                                                      ->84
   40    71    >   CAST                                          4  ~41     !6
         72        IS_SMALLER_OR_EQUAL                                      128, ~41
         73      > JMPZ                                                     ~42, ->84
   42    74    >   STRLEN                                           ~43     !4
         75        ASSIGN                                                   !7, ~43
   43    76        INIT_FCALL                                               'remapinternationalchartoascii'
         77        SEND_VAR                                                 !6
         78        DO_FCALL                                      0  $45     
         79        ASSIGN_OP                                     8          !4, $45
   45    80        STRLEN                                           ~47     !4
         81        IS_NOT_EQUAL                                             !7, ~47
         82      > JMPZ                                                     ~48, ->84
         83    >   ASSIGN                                                   !3, <false>
   47    84    >   IS_EQUAL                                                 !5, !1
         85      > JMPZ                                                     ~50, ->87
         86    > > JMP                                                      ->90
   17    87    >   PRE_INC                                                  !5
         88    >   IS_SMALLER                                               !5, !2
         89      > JMPNZ                                                    ~52, ->11
   50    90    > > JMPZ                                                     !3, ->99
   51    91    >   INIT_FCALL                                               'substr'
         92        SEND_VAR                                                 !4
         93        SEND_VAL                                                 0
         94        STRLEN                                           ~53     !4
         95        SUB                                              ~54     ~53, 1
         96        SEND_VAL                                                 ~54
         97        DO_ICALL                                         $55     
         98      > RETURN                                                   $55
   54    99    > > RETURN                                                   !4
   55   100*     > RETURN                                                   null

End of function sluggify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.29 ms | 1415 KiB | 19 Q