3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_between($the_string, $starts_with, $ends_with) { echo "before".$the_string."\n"; $the_string = substr($the_string,strpos ($the_string , $starts_with)); echo "now".$the_string."\n"; $temp = array_filter(explode($starts_with, $the_string)); $result_array = array(); $inc = 0; foreach($temp as $a_start_match) { echo $a_start_match."\n"; if (strlen($ends_with) <= strlen($a_start_match)) { $a_start_match = substr($a_start_match,0,strlen($a_start_match)-strpos($a_start_match , $ends_with)); echo "testing ".$a_start_match."\n"; if(substr($a_start_match, -strlen($ends_with)) === $ends_with) { $result_array[$inc]=$a_start_match; $inc++; } } } return $result_array; } $the_string = "some string here string_1---1-----string2 some string here string_1----2----string2 some string here string_1----3----string2"; $a = "string_1"; $b = "string2"; print_R (get_between($the_string,$a,$b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DdDI
function name:  (null)
number of ops:  12
compiled vars:  !0 = $the_string, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1---1-----string2+some+string+here+string_1----2----string2+some+string+here+string_1----3----string2'
   42     1        ASSIGN                                                   !1, 'string_1'
   43     2        ASSIGN                                                   !2, 'string2'
   45     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'get_between'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function get_between:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 63
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 63
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 62
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 62
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 62
Branch analysis from position: 62
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
filename:       /in/3DdDI
function name:  get_between
number of ops:  66
compiled vars:  !0 = $the_string, !1 = $starts_with, !2 = $ends_with, !3 = $temp, !4 = $result_array, !5 = $inc, !6 = $a_start_match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        CONCAT                                           ~7      'before', !0
          4        CONCAT                                           ~8      ~7, '%0A'
          5        ECHO                                                     ~8
    8     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !0
          8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !0, $10
    9    15        CONCAT                                           ~12     'now', !0
         16        CONCAT                                           ~13     ~12, '%0A'
         17        ECHO                                                     ~13
   11    18        INIT_FCALL                                               'array_filter'
         19        INIT_FCALL                                               'explode'
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $14     
         23        SEND_VAR                                                 $14
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !3, $15
   12    26        ASSIGN                                                   !4, <array>
   14    27        ASSIGN                                                   !5, 0
   16    28      > FE_RESET_R                                       $19     !3, ->63
         29    > > FE_FETCH_R                                               $19, !6, ->63
   18    30    >   CONCAT                                           ~20     !6, '%0A'
         31        ECHO                                                     ~20
   19    32        STRLEN                                           ~21     !2
         33        STRLEN                                           ~22     !6
         34        IS_SMALLER_OR_EQUAL                                      ~21, ~22
         35      > JMPZ                                                     ~23, ->62
   22    36    >   INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !6
         38        SEND_VAL                                                 0
         39        STRLEN                                           ~24     !6
         40        INIT_FCALL                                               'strpos'
         41        SEND_VAR                                                 !6
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                         $25     
         44        SUB                                              ~26     ~24, $25
         45        SEND_VAL                                                 ~26
         46        DO_ICALL                                         $27     
         47        ASSIGN                                                   !6, $27
   24    48        CONCAT                                           ~29     'testing+', !6
         49        CONCAT                                           ~30     ~29, '%0A'
         50        ECHO                                                     ~30
   25    51        INIT_FCALL                                               'substr'
         52        SEND_VAR                                                 !6
         53        STRLEN                                           ~31     !2
         54        MUL                                              ~32     ~31, -1
         55        SEND_VAL                                                 ~32
         56        DO_ICALL                                         $33     
         57        IS_IDENTICAL                                             !2, $33
         58      > JMPZ                                                     ~34, ->62
   27    59    >   ASSIGN_DIM                                               !4, !5
         60        OP_DATA                                                  !6
   28    61        PRE_INC                                                  !5
   16    62    > > JMP                                                      ->29
         63    >   FE_FREE                                                  $19
   34    64      > RETURN                                                   !4
   35    65*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.82 ms | 1403 KiB | 24 Q