3v4l.org

run code in 500+ PHP versions simultaneously
<?php function substr_unicode($str, $s, $l = null) { return join("", array_slice( preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l)); } $str = "Büyük"; $s = 0; // start from "0" (nth) char $l = 3; // get "3" chars echo substr($str, $s, $l) ."\n"; // Bü echo mb_substr($str, $s, $l) ."\n"; // Bü echo substr_unicode($str, $s, $l); // Büy
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EmmID
function name:  (null)
number of ops:  21
compiled vars:  !0 = $str, !1 = $s, !2 = $l
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                       !0, 'B%C3%BCy%C3%BCk'
    8     1        ASSIGN                                                       !1, 0
    9     2        ASSIGN                                                       !2, 3
   10     3        FRAMELESS_ICALL_3                substr              ~6      !0, !1
          4        OP_DATA                                                      !2
          5        CONCAT                                               ~7      ~6, '%0A'
          6        ECHO                                                         ~7
   11     7        INIT_FCALL                                                   'mb_substr'
          8        SEND_VAR                                                     !0
          9        SEND_VAR                                                     !1
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                             $8      
         12        CONCAT                                               ~9      $8, '%0A'
         13        ECHO                                                         ~9
   12    14        INIT_FCALL                                                   'substr_unicode'
         15        SEND_VAR                                                     !0
         16        SEND_VAR                                                     !1
         17        SEND_VAR                                                     !2
         18        DO_FCALL                                          0  $10     
         19        ECHO                                                         $10
         20      > RETURN                                                       1

Function substr_unicode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EmmID
function name:  substr_unicode
number of ops:  20
compiled vars:  !0 = $str, !1 = $s, !2 = $l
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV_INIT                                            !2      null
    3     3        INIT_FCALL                                                   'join'
          4        SEND_VAL                                                     ''
          5        INIT_FCALL                                                   'array_slice'
    4     6        INIT_FCALL                                                   'preg_split'
          7        SEND_VAL                                                     '%2F%2Fu'
          8        SEND_VAR                                                     !0
          9        SEND_VAL                                                     -1
         10        SEND_VAL                                                     1
         11        DO_ICALL                                             $3      
         12        SEND_VAR                                                     $3
         13        SEND_VAR                                                     !1
         14        SEND_VAR                                                     !2
    3    15        DO_ICALL                                             $4      
    4    16        SEND_VAR                                                     $4
    3    17        DO_ICALL                                             $5      
    4    18      > RETURN                                                       $5
    5    19*     > RETURN                                                       null

End of function substr_unicode

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.69 ms | 488 KiB | 12 Q