3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'Festival des arts du cirque et de la dance // Les Élancées // du 18 au 25 février // Étang de Berre'; function slugify($text) { $alphabet = array( 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ƒ'=>'f', 'ü'=>'u', 'â'=>'a' ); if(empty($text)) return 'n-a'; $text = str_replace('&', '-and-', $text); $text = strtr($text, $alphabet); // replace all non letters or digits by - $text = preg_replace('/\W+/', '-', $text); // trim and lowercase $text = strtolower(trim($text, '-')); return $text; } echo slugify($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Vo5W
function name:  (null)
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Festival+des+arts+du+cirque+et+de+la+dance+%2F%2F+Les+%C3%89lanc%C3%A9es+%2F%2F+du+18+au+25+f%C3%A9vrier+%2F%2F+%C3%89tang+de+Berre'
   30     1        INIT_FCALL                                               'slugify'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Vo5W
function name:  slugify
number of ops:  32
compiled vars:  !0 = $text, !1 = $alphabet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, <array>
   16     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~3, ->5
          4    > > RETURN                                                   'n-a'
   18     5    >   INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '%26'
          7        SEND_VAL                                                 '-and-'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !0, $4
   19    11        INIT_FCALL                                               'strtr'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !0, $6
   22    16        INIT_FCALL                                               'preg_replace'
         17        SEND_VAL                                                 '%2F%5CW%2B%2F'
         18        SEND_VAL                                                 '-'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $8      
         21        ASSIGN                                                   !0, $8
   25    22        INIT_FCALL                                               'strtolower'
         23        INIT_FCALL                                               'trim'
         24        SEND_VAR                                                 !0
         25        SEND_VAL                                                 '-'
         26        DO_ICALL                                         $10     
         27        SEND_VAR                                                 $10
         28        DO_ICALL                                         $11     
         29        ASSIGN                                                   !0, $11
   27    30      > RETURN                                                   !0
   28    31*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.45 ms | 1403 KiB | 24 Q