3v4l.org

run code in 300+ PHP versions simultaneously
<?php $val = utf8_encode("á|â|à|å|ä ð|é|ê|è|ë í|î|ì|ï ó|ô|ò|ø|õ|ö ú|û|ù|ü æ ç ß abc ABC 123"); echo iconv('UTF-8','us-ascii//TRANSLIT//IGNORE',$val); function slugify($text) { // replace non letter or digits by - $text = preg_replace('#[^\\pL\d]+#u', '-', $text); // trim $text = trim($text, '-'); // transliterate if (function_exists('iconv')) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); } // lowercase $text = strtolower($text); // remove unwanted characters $text = preg_replace('#[^-\w]+#', '', $text); if (empty($text)) { return 'n-a'; } return $text; } echo slugify(utf8_encode('é')); // --> "e"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gbZKV
function name:  (null)
number of ops:  18
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'utf8_encode'
          1        SEND_VAL                                                 '%C3%A1%7C%C3%A2%7C%C3%A0%7C%C3%A5%7C%C3%A4+%C3%B0%7C%C3%A9%7C%C3%AA%7C%C3%A8%7C%C3%AB+%C3%AD%7C%C3%AE%7C%C3%AC%7C%C3%AF+%C3%B3%7C%C3%B4%7C%C3%B2%7C%C3%B8%7C%C3%B5%7C%C3%B6+%C3%BA%7C%C3%BB%7C%C3%B9%7C%C3%BC+%C3%A6+%C3%A7+%C3%9F+abc+ABC+123'
          2        DO_ICALL                                         $1      
          3        ASSIGN                                                   !0, $1
    4     4        INIT_FCALL_BY_NAME                                       'iconv'
          5        SEND_VAL_EX                                              'UTF-8'
          6        SEND_VAL_EX                                              'us-ascii%2F%2FTRANSLIT%2F%2FIGNORE'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $3      
          9        ECHO                                                     $3
   34    10        INIT_FCALL                                               'slugify'
         11        INIT_FCALL                                               'utf8_encode'
         12        SEND_VAL                                                 '%C3%A9'
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_FCALL                                      0  $5      
         16        ECHO                                                     $5
         17      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/gbZKV
function name:  slugify
number of ops:  37
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%23%5B%5E%5CpL%5Cd%5D%2B%23u'
          3        SEND_VAL                                                 '-'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
   12     7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '-'
         10        DO_ICALL                                         $3      
         11        ASSIGN                                                   !0, $3
   15    12        INIT_FCALL                                               'function_exists'
         13        SEND_VAL                                                 'iconv'
         14        DO_ICALL                                         $5      
         15      > JMPZ                                                     $5, ->22
   17    16    >   INIT_FCALL_BY_NAME                                       'iconv'
         17        SEND_VAL_EX                                              'utf-8'
         18        SEND_VAL_EX                                              'us-ascii%2F%2FTRANSLIT'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $6      
         21        ASSIGN                                                   !0, $6
   21    22    >   INIT_FCALL                                               'strtolower'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $8      
         25        ASSIGN                                                   !0, $8
   24    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 '%23%5B%5E-%5Cw%5D%2B%23'
         28        SEND_VAL                                                 ''
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $10     
         31        ASSIGN                                                   !0, $10
   26    32        ISSET_ISEMPTY_CV                                         !0
         33      > JMPZ                                                     ~12, ->35
   28    34    > > RETURN                                                   'n-a'
   31    35    > > RETURN                                                   !0
   32    36*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
217.95 ms | 1402 KiB | 27 Q