3v4l.org

run code in 300+ PHP versions simultaneously
<?php function p_explode($del, $str, $cnt) { if (count(explode($del, $str) <= $cnt)) return [$str]; $tmp = explode($del, $str, $cnt); $last = array_pop($tmp); return array_merge($tmp, p_explode($del, $last, $cnt)); } $string ='1,2,3,4,5,6,7,8,9,10,11,12,13,14,15'; var_dump(p_explode(',', $str, 4));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4mqff
function name:  (null)
number of ops:  10
compiled vars:  !0 = $string, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, '1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11%2C12%2C13%2C14%2C15'
   14     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'p_explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 4
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function p_explode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4mqff
function name:  p_explode
number of ops:  33
compiled vars:  !0 = $del, !1 = $str, !2 = $cnt, !3 = $tmp, !4 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'explode'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        IS_SMALLER_OR_EQUAL                              ~6      $5, !2
          8        COUNT                                            ~7      ~6
          9      > JMPZ                                                     ~7, ->12
    5    10    >   INIT_ARRAY                                       ~8      !1
         11      > RETURN                                                   ~8
    7    12    >   INIT_FCALL                                               'explode'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !3, $9
    8    18        INIT_FCALL                                               'array_pop'
         19        SEND_REF                                                 !3
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !4, $11
    9    22        INIT_FCALL                                               'array_merge'
         23        SEND_VAR                                                 !3
         24        INIT_FCALL_BY_NAME                                       'p_explode'
         25        SEND_VAR_EX                                              !0
         26        SEND_VAR_EX                                              !4
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0  $13     
         29        SEND_VAR                                                 $13
         30        DO_ICALL                                         $14     
         31      > RETURN                                                   $14
   10    32*     > RETURN                                                   null

End of function p_explode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.39 ms | 1403 KiB | 22 Q