3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_split_unicode($str, $l = 0) { if ($l > 0) { $ret = array(); $len = mb_strlen($str, "UTF-8"); for ($i = 0; $i < $len; $i += $l) { $ret[] = mb_substr($str, $i, $l, "UTF-8"); } return $ret; } return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY); } $s = '中华人民abc共和\x01国'; print_r(str_split_unicode($s)); print_r(str_split_unicode($s, 3));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DABQ6
function name:  (null)
number of ops:  15
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91abc%E5%85%B1%E5%92%8C%5Cx01%E5%9B%BD'
   15     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'str_split_unicode'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   16     7        INIT_FCALL                                               'print_r'
          8        INIT_FCALL                                               'str_split_unicode'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 3
         11        DO_FCALL                                      0  $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function str_split_unicode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 12
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 12
Branch analysis from position: 23
Branch analysis from position: 12
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DABQ6
function name:  str_split_unicode
number of ops:  32
compiled vars:  !0 = $str, !1 = $l, !2 = $ret, !3 = $len, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
    3     2        IS_SMALLER                                               0, !1
          3      > JMPZ                                                     ~5, ->24
    4     4    >   ASSIGN                                                   !2, <array>
    5     5        INIT_FCALL                                               'mb_strlen'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 'UTF-8'
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !3, $7
    6    10        ASSIGN                                                   !4, 0
         11      > JMP                                                      ->21
    7    12    >   INIT_FCALL                                               'mb_substr'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !4
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 'UTF-8'
         17        DO_ICALL                                         $11     
         18        ASSIGN_DIM                                               !2
         19        OP_DATA                                                  $11
    6    20        ASSIGN_OP                                     1          !4, !1
         21    >   IS_SMALLER                                               !4, !3
         22      > JMPNZ                                                    ~13, ->12
    9    23    > > RETURN                                                   !2
   11    24    >   INIT_FCALL                                               'preg_split'
         25        SEND_VAL                                                 '%2F%2Fu'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 -1
         28        SEND_VAL                                                 1
         29        DO_ICALL                                         $14     
         30      > RETURN                                                   $14
   12    31*     > RETURN                                                   null

End of function str_split_unicode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.37 ms | 1403 KiB | 23 Q