3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slug( $string, $separator = '-' ) { $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; $special_cases = array( '&' => 'and', "'" => ''); $string = mb_strtolower( trim( $string ), 'UTF-8' ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); $string = preg_replace("/\s+/", "$separator", $string); $string = preg_replace("/[$separator]+/u", "$separator", $string); return $string; } echo slug("um rĂ¡dio bonito");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKuAV
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'slug'
          1        SEND_VAL                                                 'um+r%C3%A1dio+bonito'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function slug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKuAV
function name:  slug
number of ops:  54
compiled vars:  !0 = $string, !1 = $separator, !2 = $accents_regex, !3 = $special_cases
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '-'
    4     2        ASSIGN                                                   !2, '%7E%26%28%5Ba-z%5D%7B1%2C2%7D%29%28%3F%3Aacute%7Ccedil%7Ccirc%7Cgrave%7Clig%7Corn%7Cring%7Cslash%7Cth%7Ctilde%7Cuml%29%3B%7Ei'
    5     3        ASSIGN                                                   !3, <array>
    6     4        INIT_FCALL                                               'mb_strtolower'
          5        INIT_FCALL                                               'trim'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        SEND_VAL                                                 'UTF-8'
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !0, $7
    7    12        INIT_FCALL                                               'str_replace'
         13        INIT_FCALL                                               'array_keys'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $9      
         16        SEND_VAR                                                 $9
         17        INIT_FCALL                                               'array_values'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $10     
         20        SEND_VAR                                                 $10
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $11     
         23        ASSIGN                                                   !0, $11
    8    24        INIT_FCALL                                               'preg_replace'
         25        SEND_VAR                                                 !2
         26        SEND_VAL                                                 '%241'
         27        INIT_FCALL                                               'htmlentities'
         28        SEND_VAR                                                 !0
         29        SEND_VAL                                                 3
         30        SEND_VAL                                                 'UTF-8'
         31        DO_ICALL                                         $13     
         32        SEND_VAR                                                 $13
         33        DO_ICALL                                         $14     
         34        ASSIGN                                                   !0, $14
    9    35        INIT_FCALL                                               'preg_replace'
         36        SEND_VAL                                                 '%2F%5Cs%2B%2F'
         37        CAST                                          6  ~16     !1
         38        SEND_VAL                                                 ~16
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $17     
         41        ASSIGN                                                   !0, $17
   10    42        INIT_FCALL                                               'preg_replace'
         43        ROPE_INIT                                     3  ~20     '%2F%5B'
         44        ROPE_ADD                                      1  ~20     ~20, !1
         45        ROPE_END                                      2  ~19     ~20, '%5D%2B%2Fu'
         46        SEND_VAL                                                 ~19
         47        CAST                                          6  ~22     !1
         48        SEND_VAL                                                 ~22
         49        SEND_VAR                                                 !0
         50        DO_ICALL                                         $23     
         51        ASSIGN                                                   !0, $23
   11    52      > RETURN                                                   !0
   12    53*     > RETURN                                                   null

End of function slug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.38 ms | 1012 KiB | 21 Q