3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '___RN___RN___R___N___RN___RN'; $del = array('RN', 'R', 'N'); # This won't work if delimiters 2-n include characters from delimiter 1 var_dump(explode( $del[0], str_replace($del, $del[0], $str))); # This, however, will work function array_explode($delimiters, $string){ if(!is_array(($delimiters)) && !is_array($string)){ //if neither the delimiter nor the string are arrays return explode($delimiters,$string); } else if(!is_array($delimiters) && is_array($string)) { //if the delimiter is not an array but the string is foreach($string as $item){ foreach(explode($delimiters, $item) as $sub_item){ $items[] = $sub_item; } } return $items; } else if(is_array($delimiters) && !is_array($string)) { //if the delimiter is an array but the string is not $string_array[] = $string; foreach($delimiters as $delimiter){ $string_array = array_explode($delimiter, $string_array); } return $string_array; } } var_dump(array_explode($del,$str));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bJOkI
function name:  (null)
number of ops:  24
compiled vars:  !0 = $str, !1 = $del
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '___RN___RN___R___N___RN___RN'
    4     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'explode'
          4        FETCH_DIM_R                                      ~4      !1, 0
          5        SEND_VAL                                                 ~4
          6        INIT_FCALL                                               'str_replace'
          7        SEND_VAR                                                 !1
          8        FETCH_DIM_R                                      ~5      !1, 0
          9        SEND_VAL                                                 ~5
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   32    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'array_explode'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !0
         20        DO_FCALL                                      0  $9      
         21        SEND_VAR                                                 $9
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function array_explode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 37
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 34
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 32
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 55
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 53
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 20
Branch analysis from position: 8
filename:       /in/bJOkI
function name:  array_explode
number of ops:  56
compiled vars:  !0 = $delimiters, !1 = $string, !2 = $item, !3 = $sub_item, !4 = $items, !5 = $string_array, !6 = $delimiter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        TYPE_CHECK                                  128  ~7      !0
          3        BOOL_NOT                                         ~8      ~7
          4      > JMPZ_EX                                          ~8      ~8, ->8
          5    >   TYPE_CHECK                                  128  ~9      !1
          6        BOOL_NOT                                         ~10     ~9
          7        BOOL                                             ~8      ~10
          8    > > JMPZ                                                     ~8, ->15
   13     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13      > RETURN                                                   $11
   11    14*       JMP                                                      ->55
   14    15    >   TYPE_CHECK                                  128  ~12     !0
         16        BOOL_NOT                                         ~13     ~12
         17      > JMPZ_EX                                          ~13     ~13, ->20
         18    >   TYPE_CHECK                                  128  ~14     !1
         19        BOOL                                             ~13     ~14
         20    > > JMPZ                                                     ~13, ->37
   16    21    > > FE_RESET_R                                       $15     !1, ->34
         22    > > FE_FETCH_R                                               $15, !2, ->34
   17    23    >   INIT_FCALL                                               'explode'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $16     
         27      > FE_RESET_R                                       $17     $16, ->32
         28    > > FE_FETCH_R                                               $17, !3, ->32
   18    29    >   ASSIGN_DIM                                               !4
         30        OP_DATA                                                  !3
   17    31      > JMP                                                      ->28
         32    >   FE_FREE                                                  $17
   16    33      > JMP                                                      ->22
         34    >   FE_FREE                                                  $15
   21    35      > RETURN                                                   !4
   14    36*       JMP                                                      ->55
   22    37    >   TYPE_CHECK                                  128  ~19     !0
         38      > JMPZ_EX                                          ~19     ~19, ->42
         39    >   TYPE_CHECK                                  128  ~20     !1
         40        BOOL_NOT                                         ~21     ~20
         41        BOOL                                             ~19     ~21
         42    > > JMPZ                                                     ~19, ->55
   24    43    >   ASSIGN_DIM                                               !5
         44        OP_DATA                                                  !1
   25    45      > FE_RESET_R                                       $23     !0, ->53
         46    > > FE_FETCH_R                                               $23, !6, ->53
   26    47    >   INIT_FCALL_BY_NAME                                       'array_explode'
         48        SEND_VAR_EX                                              !6
         49        SEND_VAR_EX                                              !5
         50        DO_FCALL                                      0  $24     
         51        ASSIGN                                                   !5, $24
   25    52      > JMP                                                      ->46
         53    >   FE_FREE                                                  $23
   28    54      > RETURN                                                   !5
   30    55    > > RETURN                                                   null

End of function array_explode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.48 ms | 1473 KiB | 17 Q