3v4l.org

run code in 300+ PHP versions simultaneously
<?php function explodeCustom($delimiter, $string) { $arr = array(); $deli_strlen = strlen($delimiter); while ($string) { $pos = strpos($string, $delimiter); if ($pos === false) { $arr[] = $string; $string = ''; } else { $arr[] = substr($string, 0, $pos); $string = substr($string, $pos + $deli_strlen); } } return $arr; } print_r(explodeCustom('aa', ',,aaa,,a,a,aa,')); print_r(explode('aa', ',,aaa,,a,a,aa,'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5M0as
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'explodecustom'
          2        SEND_VAL                                                 'aa'
          3        SEND_VAL                                                 '%2C%2Caaa%2C%2Ca%2Ca%2Caa%2C'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   20     7        INIT_FCALL                                               'print_r'
          8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 'aa'
         10        SEND_VAL                                                 '%2C%2Caaa%2C%2Ca%2Ca%2Caa%2C'
         11        DO_ICALL                                         $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function explodecustom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
Branch analysis from position: 6
filename:       /in/5M0as
function name:  explodeCustom
number of ops:  33
compiled vars:  !0 = $delimiter, !1 = $string, !2 = $arr, !3 = $deli_strlen, !4 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        STRLEN                                           ~6      !0
          4        ASSIGN                                                   !3, ~6
    6     5      > JMP                                                      ->30
    7     6    >   INIT_FCALL                                               'strpos'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !4, $8
    8    11        TYPE_CHECK                                    4          !4
         12      > JMPZ                                                     ~10, ->17
    9    13    >   ASSIGN_DIM                                               !2
         14        OP_DATA                                                  !1
   10    15        ASSIGN                                                   !1, ''
         16      > JMP                                                      ->30
   12    17    >   INIT_FCALL                                               'substr'
         18        SEND_VAR                                                 !1
         19        SEND_VAL                                                 0
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                         $14     
         22        ASSIGN_DIM                                               !2
         23        OP_DATA                                                  $14
   13    24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !1
         26        ADD                                              ~15     !4, !3
         27        SEND_VAL                                                 ~15
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !1, $16
    6    30    > > JMPNZ                                                    !1, ->6
   16    31    > > RETURN                                                   !2
   17    32*     > RETURN                                                   null

End of function explodecustom

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.1 ms | 1403 KiB | 22 Q