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 = 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/ugOJ2
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 = 26, Position 2 = 60
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 60
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 59
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 59
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 59
Branch analysis from position: 59
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
filename:       /in/ugOJ2
function name:  get_between
number of ops:  63
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                                               'explode'
         19        SEND_VAR                                                 !1
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $14     
         22        ASSIGN                                                   !3, $14
   12    23        ASSIGN                                                   !4, <array>
   14    24        ASSIGN                                                   !5, 0
   16    25      > FE_RESET_R                                       $18     !3, ->60
         26    > > FE_FETCH_R                                               $18, !6, ->60
   18    27    >   CONCAT                                           ~19     !6, '%0A'
         28        ECHO                                                     ~19
   19    29        STRLEN                                           ~20     !2
         30        STRLEN                                           ~21     !6
         31        IS_SMALLER_OR_EQUAL                                      ~20, ~21
         32      > JMPZ                                                     ~22, ->59
   22    33    >   INIT_FCALL                                               'substr'
         34        SEND_VAR                                                 !6
         35        SEND_VAL                                                 0
         36        STRLEN                                           ~23     !6
         37        INIT_FCALL                                               'strpos'
         38        SEND_VAR                                                 !6
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                         $24     
         41        SUB                                              ~25     ~23, $24
         42        SEND_VAL                                                 ~25
         43        DO_ICALL                                         $26     
         44        ASSIGN                                                   !6, $26
   24    45        CONCAT                                           ~28     'testing+', !6
         46        CONCAT                                           ~29     ~28, '%0A'
         47        ECHO                                                     ~29
   25    48        INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !6
         50        STRLEN                                           ~30     !2
         51        MUL                                              ~31     ~30, -1
         52        SEND_VAL                                                 ~31
         53        DO_ICALL                                         $32     
         54        IS_IDENTICAL                                             !2, $32
         55      > JMPZ                                                     ~33, ->59
   27    56    >   ASSIGN_DIM                                               !4, !5
         57        OP_DATA                                                  !6
   28    58        PRE_INC                                                  !5
   16    59    > > JMP                                                      ->26
         60    >   FE_FREE                                                  $18
   34    61      > RETURN                                                   !4
   35    62*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.37 ms | 1394 KiB | 22 Q